How to uplaod on pypi.test with 2fa?

80 Views Asked by At

I try to update my package and test it on pypi.test. But now it is required to set up a 2 factor authentication method (2fa). I set it up, but still can not upload. Why ?

Here is what I tried :

(main) ostocker@ospc2:~/travaux/OSToolBox$ python -m twine upload --repository-url 
https://test.pypi.org/legacy/ dist/* 
Uploading distributions to https://test.pypi.org/legacy/
Enter your username: nanblanc
Enter your password: 
Uploading OSToolBox-1.5-py3-none-any.whl
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.8/14.8 kB • 00:00 • 137.4 MB/s
WARNING  Error during upload. Retry with the --verbose option for more details.                     
ERROR    HTTPError: 401 Unauthorized from https://test.pypi.org/legacy/                             
         User NanBlanc has two factor auth enabled, an API Token or Trusted Publisher must be used  
         to upload in place of password.   

This means I need to use the code generated by google authenticator:

(main) ostocker@ospc2:~/travaux/OSToolBox$ python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* 
Uploading distributions to https://test.pypi.org/legacy/
Enter your username: nanblanc
Enter your password: 
Uploading OSToolBox-1.5-py3-none-any.whl
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.8/14.8 kB • 00:00 • 123.2 MB/s
WARNING  Error during upload. Retry with the --verbose option for more details.                     
ERROR    HTTPError: 403 Forbidden from https://test.pypi.org/legacy/                                
         Invalid or non-existent authentication information. See                                    
         https://test.pypi.org/help/#invalid-auth for more information.

I can not understand this error. If it isn't the 2fa code that I should use, what do I need to use then? (I tried password with and without the space: "XXXXXX" or "XXX XXX", doesn't change a thing)

0

There are 0 best solutions below