pypa / twine

Utilities for interacting with PyPI
https://twine.readthedocs.io/
Apache License 2.0
1.61k stars 308 forks source link

doc: using keyring with API key #1119

Open bukzor opened 4 months ago

bukzor commented 4 months ago

Show how to use twine+keyring post 2024-01-01.

This is my attempt to prevent anyone else from being bitten by this change:

auth.py

    def username(self) -> Optional[str]:
        if cast(str, self.config["repository"]).startswith(
            (utils.DEFAULT_REPOSITORY, utils.TEST_REPOSITORY)
        ):
            # As of 2024-01-01, PyPI requires API tokens for uploads, meaning
            # that the username is invariant.
            return "__token__"