Skip to content

Commit 76f3683

Browse files
bukzorjaraco
andauthored
doc: using keyring with API key (#1119)
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` ```python 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__" ``` Co-authored-by: Jason R. Coombs <[email protected]>
1 parent 803796e commit 76f3683

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

docs/index.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,17 @@ require `additional installation steps`_.
192192
Once Twine is installed, use the ``keyring`` program to set a username and
193193
password to use for each repository to which you may upload.
194194

195-
For example, to set a username and password for PyPI:
195+
For example, to set an API token for PyPI:
196196

197197
.. code-block:: bash
198198
199-
keyring set https://upload.pypi.org/legacy/ your-username
199+
keyring set https://upload.pypi.org/legacy/ __token__
200200
201-
and enter the password when prompted.
201+
and paste your API key when prompted.
202202

203203
For a different repository, replace the URL with the relevant repository
204204
URL. For example, for Test PyPI, use ``https://test.pypi.org/legacy/``.
205205

206-
The next time you run ``twine``, it will prompt you for a username, and then
207-
get the appropriate password from Keyring.
208-
209206
.. note::
210207

211208
If you are using Linux in a headless environment (such as on a

0 commit comments

Comments
 (0)