Skip to content
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

flit publish fails, 403 Client Error: Username/Password authentication is no longer supported. #686

Open
iamjameswalters opened this issue Jul 6, 2024 · 2 comments

Comments

@iamjameswalters
Copy link

Running Pop OS 22.04, Python 3.10.12, Flit 3.9.0.

When running flit publish, I get the following output:

james@devone:~/git/pible/src$ flit publish
/usr/lib/python3/dist-packages/requests/__init__.py:87: RequestsDependencyWarning: urllib3 (2.2.1) or chardet (4.0.0) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Found 78 files tracked in git                                                           I-flit.sdist
Built sdist: dist/pible-0.1.tar.gz                                                 I-flit_core.sdist
Copying package file(s) from /tmp/tmpkkeddu7v/pible-0.1/pible                      I-flit_core.wheel
Writing metadata files                                                             I-flit_core.wheel
Writing the record of files                                                        I-flit_core.wheel
Built wheel: dist/pible-0.1-py2.py3-none-any.whl                                   I-flit_core.wheel
Using repository at https://upload.pypi.org/legacy/                                    I-flit.upload
Uploading dist/pible-0.1-py2.py3-none-any.whl...                                       I-flit.upload
Traceback (most recent call last):
  File "/home/james/.local/bin/flit", line 8, in <module>
    sys.exit(main())
  File "/home/james/.local/lib/python3.10/site-packages/flit/__init__.py", line 200, in main
    main(args.ini_file, repository, args.pypirc, formats=set(args.format or []),
  File "/home/james/.local/lib/python3.10/site-packages/flit/upload.py", line 277, in main
    do_upload(built.wheel.file, built.wheel.builder.metadata, pypirc_path, repo_name)
  File "/home/james/.local/lib/python3.10/site-packages/flit/upload.py", line 252, in do_upload
    upload_file(file, metadata, repo)
  File "/home/james/.local/lib/python3.10/site-packages/flit/upload.py", line 245, in upload_file
    resp.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Username/Password authentication is no longer supported. Migrate to API Tokens or Trusted Publishers instead. See https://pypi.org/help/#apitoken and https://pypi.org/help/#trusted-publishers for url: https://upload.pypi.org/legacy/

Flit doesn't ask me for a username and password. I've tried setting them (using __token__ and my token) using environment variables and a .pypirc, neither of them work.

Using twine upload dist/* asked me for my API token and then uploaded correctly.

Is there something I'm missing? Otherwise this seems like a serious bug.

@takluyver
Copy link
Member

That's curious. I've definitely been able to upload successfully by setting the environment variables FLIT_USERNAME=__token__ FLIT_PASSWORD=pypi-... when uploading.

I've also done it with tokens saved in keyring - the username should be like pypi_token:project:<project> or pypi_token:user:<user>, replacing the last part with the relevant project name or username.

I want to make a better story around uploading with tokens, but the way I want to approach it requires an API to create tokens on PyPI, and that doesn't exist (pypi/warehouse#6396 ).

@iamjameswalters
Copy link
Author

Would love to do anything I can to help troubleshoot this. Started fresh with a dummy project following the example on the README, and I'm still encountering this error or variations of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants