401 Unauthorized from https://test.pypi.org/legacy/

796 views Asked by At

I am using this cmd on windows to upload my package in testpypi twine upload -r testpypi dist/* but it's showing this error. so how to upload in testpypi and pypi when 2FA is enable ?

Uploading mypackage-0.1.0-py3-none-any.whl
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.5/8.5 kB • 00:00 • ?
WARNING  Error during upload. Retry with the --verbose option for more details.
ERROR    HTTPError: 401 Unauthorized from https://test.pypi.org/legacy/
         User has two factor auth enabled, an API Token or Trusted Publisher must be used to upload in place of password.
1

There are 1 answers

2
zircon On BEST ANSWER

create API token from your pypi account then give username =__token__ and password=APITokenafter cmd twine upload -r testpypi dist/*

or if you are using Twine to upload your projects to PyPI, set up your $HOME/.pypirc file like this:

[testpypi]
  username = __token__
  password = API Token