Skip to content

fix(publish): pypi trusted publishing always requests the pypi audience #1344

Closed

Description

@BryanFRD

What is wrong

pypi_oidc::mint always requests the GitHub OIDC token with audience=pypi (AUDIENCE const,

const AUDIENCE: &str = "pypi";
and audience_url at L71-L74), while the mint endpoint is derived from the registry url (L76-L92).

Warehouse instances do not share an audience: TestPyPI expects testpypi, and each index advertises its own at https://<host>/_/oidc/audience (this is what pypa/gh-action-pypi-publish queries). So with url: https://test.pypi.org/legacy/ and trustedPublishing: true, the exchange at https://test.pypi.org/_/oidc/mint-token is refused, and the error tells the user to check their trusted publisher registration, which is not the problem.

The config docs say the opposite: "The token endpoint is derived from the registry url, so TestPyPI and a private index work unchanged" (docs/site/docs-en/configuration/config-file.md:1084).

Suggested fix

GET https://<host>/_/oidc/audience first and request the OIDC token with the returned audience, falling back to pypi only for pypi.org if the call fails. Add a test against the test server for a non-default audience.

Activity

  1. added a commit that references this issue on Nov 9, 2026
    07919a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions