Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyPI rejects token authentication on upload from Windows

During an attempt to upload a python package to the testpypi repository with py -m twine upload --verbose --repository testpypi dist/* twine fails with the message,

403 Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.

The provided link states,

If you’re using Windows and trying to paste your username, password, or token in the Command Prompt or PowerShell, Ctrl-V and Shift+Insert won’t work. Instead, you can use “Edit > Paste” from the window menu, or enable “Use Ctrl+Shift+C/V as Copy/Paste” in “Properties”. This is a known issue with Python’s getpass module

The package is built with PEP517 setuptools on Windows 10 Professional. I have rebuilt the token in my account, copied the API token with the provided API copy button, pasted with the Edit > Paste menu item as specified, but twine still does not upload the package. So the Edit > Paste suggestion is not a solution.

How to do this from Windows?

like image 886
Colin Helms Avatar asked Dec 05 '25 16:12

Colin Helms


1 Answers

One approach that works is to paste the generated api token into a .pypirc file located in the $Home directory. This file has with content:

[testpypi]
  username = __token__
  password = pypi-AgEN...fki6A

[pypi]
  username = __token__
  password = pypi-XcvB...aLd6

Where the password is copied from the generated api token. One downside of this approach is that I don't see a syntax that allows for multiple tokens for a single server.

like image 106
Colin Helms Avatar answered Dec 08 '25 06:12

Colin Helms



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!