Search code examples
pythonpippypitwine

How to upload package to PyPi with Two Factor enabled?


I would like to upload a package to Pypi so I have created an account and tried to follow the manual.

  1. Account:

It looks I cannot create projects from pypi.org directly:

enter image description here

  1. I installed twine and I did
python3 -m twine upload dist/*

This time I have the following error:

HTTPError: 403 Client Error: Invalid or non-existent 
authentication information. for url: https://upload.pypi.org/legacy/

Perhaps this is related to my Two Factor Authentication. I am also curious about he legacy word used there.

If I disable the Two Factor Authentication it works...


Solution

  • From https://pypi.org/help/#twofa:

    Users who have chosen to set up two factor authentication will be asked to provide their second method of identity verification during the log in process. This only affects logging in via a web browser, and not (yet) package uploads.

    You can use API tokens instead.