PyPI Introduces “Trusted Publishers”

by: Dustin Ingram ·

2023-04-20

Starting today, PyPI package maintainers can adopt a new, more secure
publishing method that does not require long-lived passwords or API tokens to
be shared with external systems.

About trusted publishing

“Trusted publishing” is our term for using the OpenID Connect (OIDC) standard
to exchange short-lived identity tokens between a trusted third-party service
and PyPI. This method can be used in automated environments and eliminates the
need to use username/password combinations or manually generated API tokens to
authenticate with PyPI when publishing.

Instead, PyPI maintainers can configure PyPI to trust an identity provided by a
given OpenID Connect Identity Provider (IdP). This allows allows PyPI to verify
and delegate trust to that identity, which is then authorized to request
short-lived, tightly-scoped API tokens from PyPI. These API tokens never need
to be stored or shared, rotate automatically by expiring quickly, and provide a
verifiable link between a published package and its source.

Using trusted publishing with GitHub Actions

PyPI currently supports trusted publishing with GitHub Actions, using their
support for OpenID Connect
.

After configuring PyPI to trust a given GitHub repository and workflow, users
of the PyPA’s ‘pypi-publish’ GitHub Action can adopt trusted publishing by
removing the username and password fields from their workflow
configuration, and adding permissions to generate an identity token:

jobs:
   pypi-publish:
     name: upload release to PyPI
     runs-on: ubuntu-latest
+    permissions:
+      # IMPORTANT: this permission is mandatory for trusted publishing
+      id-token: write
     steps:
       # retrieve your distributions here

       - name: Publish package distributions to PyPI
         uses: pypa/gh-action-pypi-publish@release/v1
-        with:
-          username: __token__
-          password: ${{ secrets.PYPI_TOKEN }}

Using the PyPA’s GitHub action is strongly recommended, but not required. More
details on how to manually exchange tokens are available in our
documentation
.

Additional security hardening is available

PyPI package maintainers can further increase the security of their release
workflows by configuring trusted publishers to only release from a specific
GitHub Actions environment.

Configuring an environment is optional, but strongly recommended: with a GitHub
environment, you can apply additional restrictions to your trusted GitHub
Actions workflow, such as requiring manual approval on each run by a trusted
subset of repository maintainers.

Unblocking future security improvements

In addition to making publishing more secure now, the availability of trusted
publishers unblocks additional future security improvements for PyPI.

Configuring and using a trusted publisher provides a ‘strong link’ between a
project and its source repository, which can allow PyPI to verify related
metadata, like the URL of a source repository for a project1. Additionally,
publishing with a trusted publisher allows PyPI to correlate more information
about where a given file was published from in a verifiable way.

Finally, although trusted publishers is currently limited to GitHub Actions,
much of the underlying work that went into making this feature possible is
generalizable and not specific to a single publisher. We’re interested in
supporting the ability to publish from additional services that provide OpenID
Connect identities.

Get started today

To get started with using trusted publishers on PyPI, see our documentation
here: https://docs.pypi.org/trusted-publishers/.

Acknowledgements

Funding for this work was provided by the Google Open Source Security Team, and
much of the development work was performed by Trail of Bits, with special
thanks to contributor William Woodruff.

Many thanks as well to Sviatoslav Sydorenko, maintainer of the PyPA’s
‘pypi-publish’ GitHub Action for his quick and timely work to add support for
trusted publishers in the action.

Finally, we want to thank all our beta testers, including GitHub staff, for
working with us to ensure this feature is intuitive and useful, and for
providing valuable feedback to improve this feature along the way.


Dustin Ingram is a maintainer of the Python Package Index and a director of
the Python Software Foundation.

Read More
Blythe Drews

Latest

Airline spends four days without flying as bankruptcy rumors swirl

Please enable JS and disable any ad blocker

3 AI Memory Stocks to Watch in July 2026

AI memory stocks have been the loudest trade of 2026, as the scramble for the chips behind every AI server pushed prices and profits to records. But the three names below share the same strange split. The business has never looked stronger, yet the money flows are quietly turning cautious...

Zoomex X Space recap with David James and the World Cup trading panel

James said real pressure for keepers comes in the silence between shots. At Liverpool, City, Portsmouth and England, preparation shaped James. For traders too, instinct works only when built on the right information. Zoomex hosted the third episode of its World Cup Edition X Space as part of the Zoomex World Cup Impact Pledge, bringing

Kalyan Jewellers shares fall 6% despite 38% revenue growth in Q1

Home Market News Kalyan Jewellers shares fall 7% despite 38% revenue growth in Q1 Kalyan Jewellers' international business also maintained strong momentum, with revenue rising nearly 35% year-on-year. 2 Min Read Shares of Kalyan Jewellers India Ltd. fell as much as 7.5% in early trading on Tuesday, July 7, despite the jewellery retailer reported a

Newsletter

Don't miss

Airline spends four days without flying as bankruptcy rumors swirl

Please enable JS and disable any ad blocker

3 AI Memory Stocks to Watch in July 2026

AI memory stocks have been the loudest trade of 2026, as the scramble for the chips behind every AI server pushed prices and profits to records. But the three names below share the same strange split. The business has never looked stronger, yet the money flows are quietly turning cautious...

Zoomex X Space recap with David James and the World Cup trading panel

James said real pressure for keepers comes in the silence between shots. At Liverpool, City, Portsmouth and England, preparation shaped James. For traders too, instinct works only when built on the right information. Zoomex hosted the third episode of its World Cup Edition X Space as part of the Zoomex World Cup Impact Pledge, bringing

Kalyan Jewellers shares fall 6% despite 38% revenue growth in Q1

Home Market News Kalyan Jewellers shares fall 7% despite 38% revenue growth in Q1 Kalyan Jewellers' international business also maintained strong momentum, with revenue rising nearly 35% year-on-year. 2 Min Read Shares of Kalyan Jewellers India Ltd. fell as much as 7.5% in early trading on Tuesday, July 7, despite the jewellery retailer reported a

‘Worst thing about Cristiano Ronaldo’: Messi fan’s farewell to CR7 goes viral after Portugal vs Spain | World Cup 2026

Verified Messi fan Appie Cule has posted a lengthy farewell to Cristiano Ronaldo. This came after Spain beat Portugal 1-0 at the World Cup. That defeat effectively ended Ronaldo's World Cup career for good. Cule framed the post as Ronaldo's definitive "last dance" moment. The post argued Ronaldo had set impossibly-high standards for himself. It

Business seminar in Munich highlights Hong Kong’s strategic roles amidst global shifts (with photos)

Business seminar in Munich highlights Hong Kong's strategic roles amidst global shifts (with photos) ******************************************************************************************      The Hong Kong Economic and Trade Office, Berlin (HKETO Berlin), promoted Hong Kong's unique advantages and strategic roles at the seminar "Hong Kong's strategic role amidst geopolitical tensions" on June 18 (Munich time) in Munich, Germany.             Senior executives, investors

AI for business services: From job fears to productivity

AI for business services: From job fears to productivity

Business Insurance-AZ Achieves Record Response Times for 2026 Arizona Construction Bids

Business Insurance-AZ achieves milestone response speeds for commercial construction bids across Arizona, accelerating documentation delivery to keep local projects moving forward without delay. Phoenix, AZ, June 06-2026, ZEX PR WIRE — Business Insurance-AZ has achieved record-breaking processing speeds and response times for commercial construction bids throughout Arizona, directly supporting the state’s massive infrastructure and advanced manufacturing boom