Twine: 403 Client Error: Invalid or non-existent authentication information.

Created on 7 Nov 2018  路  15Comments  路  Source: pypa/twine

Your Environment

1) Your operating system: Ubuntu 18.10

2) Version of python you are running:

Python 2.7.15+

3) How did you install twine? Did you use your operating system's package manager or pip or something else?

I followed instructions at https://pypi.org/project/twine/

pip install twine

Then when I tried to run it, I was instructed to run:

sudo apt install twine

4) Version of twine you have installed (include complete output of):

twine version 1.11.0 (pkginfo: 1.4.2, requests: 2.18.4, setuptools: 40.2.0,
requests-toolbelt: 0.8.0, tqdm: 4.23.4)

5) Which package repository are you targeting?

I don't know what this means.

$ cat darip.egg-info/PKG-INFO 
Metadata-Version: 1.0
Name: darip
Version: 1.0.0
Summary: Bulk downloads images from Deviant Art
Home-page: https://github.com/kstenerud/darip/
Author: Karl Stenerud
Author-email: [email protected]
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN
$ cat ~/.pypirc 
cat: /home/karl/.pypirc: No such file or directory

The Issue

I get an HTTP error following the instructions at https://pypi.org/project/twine/

Steps to Reproduce

If the issue is predictable and consistently reproducible, please list the steps here.

$ twine upload --repository-url https://test.pypi.org/legacy/ dist/*
Uploading distributions to https://test.pypi.org/legacy/
Enter your username: kstenerud
Enter your password: 
Uploading darip-1.0.0-py2-none-any.whl
100%|鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 8.02k/8.02k [00:00<00:00, 9.58kB/s]
HTTPError: 403 Client Error: Invalid or non-existent authentication information. for url: https://test.pypi.org/legacy/
support

Most helpful comment

Instead of
twine upload --repository-url https://test.pypi.org/legacy/ dist/*

write
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

I was also having same problem but by typing commands this way, my problem got solved.

All 15 comments

https://test.pypi.org/user/kstenerud/ does not exist. You have to create your login there first.

The error message could be improved by PyPI but is not in the domain of Twine in my opinion.

Wow at first I was like "cool there is a test mechanism before publishing" and thanks to this issue I realize I had to create another account ?! what's the point pypi folks !! Please return a better message (I know this is not a pypi website but if anyone from there comes across. hope they can read it).

Instead of
twine upload --repository-url https://test.pypi.org/legacy/ dist/*

write
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

I was also having same problem but by typing commands this way, my problem got solved.

Instead of
twine upload --repository-url https://test.pypi.org/legacy/ dist/*

write
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

I was also having same problem but by typing commands this way, my problem got solved.

the perfect solution

@Foxgeek36 and @Kamleshgupta1:

The correct solution when --repository-url https://test.pypi.org/legacy/ fails due to Invalid or non-existent authentication information is to create an account on https://test.pypi.org/, which is "a separate instance of the Python Package Index that allows you to try distribution tools and processes without affecting the real index."

Using --repository-url https://upload.pypi.org/legacy/ will upload your package to https://pypi.org/, which publishes it "for real".

hi,
when we enter the password, the password is definitely not wrong and I think it's a bug. so I try to use -u for the username and -p for the password directly without using the fields provided by the console (default).
I try to run this in the command: twine upload -u YOUR-USERNAME -p YOUR-PASSWORD - repository-url https://test.pypi.org/legacy/ dist / *
Capture_distribute_packages_upload_2
it really works for me.
thanks:)

Same error

uploading to https://upload.pypi.org/legacy/
twine==2.0.0
Python 3.7.5
username and password set in .pypirc

@reubano Can you show the exact twine command that you ran, with the output? Also, what's your username on PyPI?

twine upload dist/*
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
twine upload --repository-url https://upload.pypi.org/legacy/ dist/* --password password 

@reubano I'm afraid that's not enough information. Notably missing is the output of the commands, and the username that's in .pypirc.

That said, I'm fairly confident that this is not an issue with Twine, but rather a configuration issue. I think you might get more help by posting a detailed issue at https://github.com/pypa/packaging-problems.

I tried @adamcanray solution, and it's working. The only thing i need to do is to put '' around user name and password; otherwise, it fails.

twine upload -u 'YOUR-USERNAME' -p 'YOUR-PASSWORD' - repository-url https://test.pypi.org/legacy/ dist / *

Thanks @vsay01 and @adamcanray this worked!

twine upload -u 'USERNAME' -p 'PASSWORD' --repository-url https://upload.pypi.org/legacy/ dist/*

Here are my other config options

.pypirc

[distutils]
  index-servers =
    pypi

[pypi]
  repository: https://upload.pypi.org/legacy/
  username: reubano
  password:

.localrc

export TWINE_USERNAME=reubano

After more trouble shooting, the bare minimum working command is twine upload --repository-url https://upload.pypi.org/legacy/ dist/* I think the .pypirc username config var is now being read.

@reubano I'm glad this is working for you. FWIW, since twine has defaults for pypi, I think this should be sufficient:

.pypirc

[pypi]
username: reubano
password: 

Command:

twine upload dist/*

That said, I would recommend not storing your password in .pypirc or an environment variable, but rather using keyring.

Even better would be to use PyPI API tokens instead of your username/password.

I had this same issue uploading dist to test.pypi.org.
Invalid or non-existent authentication information

Although, in my case the problem was simply because my email address was not verified.
I referred to PyPi web site, gone to Account Settings page and Verified my email.

After that my twine upload --repository-url https://test.pypi.org/legacy/ dist/* worked well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bhrutledge picture bhrutledge  路  4Comments

shivam-kotwalia picture shivam-kotwalia  路  4Comments

PyDataBlog picture PyDataBlog  路  9Comments

myw picture myw  路  3Comments

reinout picture reinout  路  6Comments