-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to upload packages using token auth due to 403 errors #577
Comments
At first glance, the command-line looks correct. Pardon the question, but are you sure you're using the correct token? For |
Thank you for the pointer. I did not know that the test repo required a separate account. I have created an account and succesfully uploaded to test using command line arguments. Given that, I've deleted my old tokens in the real pypi index and created a new one. I managed to succesfully upload my package via command line in Windows 10. However, after updating gitlab runner variables to the correct values I could not upload the package. It seems that gitlab was not setting my environment variables as the pipeline I was running on was not a "protected" job and twine was not warning me that it did not have any credentials to use. It would be nice to have a feature that warns you about not having credentials before getting a 403 error. Please feel free to close the issue if the feature above is not desired. Thank you for the support and fast response. |
I'm glad you were able to figure it out.
I read that as "Twine could give a more helpful message than Also, maybe Twine's documentation could be more explicit about using tokens and the distinction between PyPI and Test PyPI. Thus far we've been relying on the Packaging User Guide and the PyPI help. Suggestions welcome. |
What I meant is that twine did not have a configuration file, I had not passed any user credentials and there were no environment variables related to authentication. In that case, when a 403 error is returned by the server, it could be useful for the user to know that no credentials were set. I was believing that they were set via env variables but due to configuration issues, it was not the case. Thank you! |
Hi @bhrutledge I wanted to contribute towards fixing this. I think we can raise a custom exception at https://github.com/pypa/twine/blob/master/twine/utils.py#L144 like |
@deveshks Thanks for offering to help! I haven't really thought about this since February, and your comment reminded me that I've been wanting to write up an issue to refactor/normalize how Twine handles custom exceptions. So, while I think something However, I also don't want to stifle your interest. So, could you propose what message(s) would get displayed to the user? A related issue is #424, in which folks also seem to be confused about needing different credentials for PyPI and TestPyPI. |
Hi @bhrutledge ,
From what I understand, we can either provide username and password explicitly in I think that we can also read these details from the env variables
This can be resolved if for e.g. we have a way to 1. Find if the provided user exists for either PyPI/TestPyPI. and 2. If the provided user exists but the authentication info is wrong. If we encourage them to use keyring to store these for different repo urls, we can perform 1 and 2 on the keyring backend instead. From what I understood Also I got to know about twine from @brainwane over at the pypa-dev IRC channel, so I would also want to thank her for introducing me to the project. I have made some contributions to the pip repo in the past few weeks, and I am willing to take on some of the outstanding issues here as well :) |
@deveshks I started to write up an issue to add a custom exception as we've discussed, but then I discovered that the 403 response from PyPI now includes a URL for more information:
I'm inclined to rely on that, rather than duplicate the content here. That said, I've opened pypi/warehouse#7812 to add a little more to the PyPI help, and #587 to make Twine's formatting clearer. With that in mind, I'm going to close this issue, though if folks feel strongly otherwise, it can be re-opened. |
Your Environment
Your operating system:
Windows 10
Version of python you are running:
Python 3.7.4
How did you install twine? Did you use your operating system's package manager or pip or something else?
pip
Version of twine you have installed (include complete output of):
twine version 3.1.1 (pkginfo: 1.5.0.1, requests: 2.22.0, setuptools: 40.8.0, requests-toolbelt: 0.9.1, tqdm: 4.42.1)
Which package repository are you targeting?
Ideally twine default repo (I believe it is
https://upload.pypi.org/legacy/
) but due to failures I am testing againsthttps://test.pypi.org/legacy/
.PKG-INFO.txt
I am not using a
.pypirc
file but rather settingTWINE_USERNAME
andTWINE_PASSWORD
environment variables in my Gitlab CI runner.The Issue
I am unable to perform an upload using a token. I always get a 403 error. I have tryed using the
-u
and-p
parameters in order to see if that worked but this was unsucessful also.I have tryed to generate other tokens and did not suceed.
Steps to Reproduce
Just try to upload a package using a token.
The text was updated successfully, but these errors were encountered: