python-project-template icon indicating copy to clipboard operation
python-project-template copied to clipboard

Github actions PYPI_API_TOKEN not working for me

Open drbecavin opened this issue 2 years ago • 7 comments

Describe the bug Hello Thanks for your awesome template! Everything from your template is working fine,. I have only two problems: one with writing VERSION number on MACOSX (see other issue) and one with github workflows for the release. Maybe I do it wrong. GitHub actions crashes at the end of the release.yaml.

Uploading checkatlas-0.0.8-py3-none-any.whl
25l
  0%━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━0.0/36.5 kB • --:-- • ?
  0%━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━0.0/36.5 kB • --:-- • ?
100%━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━36.5/36.5 kB • 00:00 • 32.1 MB/s
100%━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━36.5/36.5 kB • 00:00 • 32.1 MB/s
25hINFO     Response from https://upload.pypi.org/legacy/:
         403 Invalid or non-existent authentication information. See            
        [ https://pypi.org/help/#inv](https://pypi.org/help/#invalid-auth)alid-auth for more information.      
INFO     <html>                                                                 
          <head>                                                                
           <title>403 Invalid or non-existent authentication information. See   
        [ https://pypi.org/help/#inv](https://pypi.org/help/#invalid-auth)alid-auth for more information.</titl
          </head>                                                               
          <body>                                                                
           <h1>403 Invalid or non-existent authentication information. See      
        [ https://pypi.org/help/#inv](https://pypi.org/help/#invalid-auth)alid-auth for more information.</h1> 
           Access was denied to this resource.<br/><br/>                        
         Invalid or non-existent authentication information. See                
        [ https://pypi.org/help/#inv](https://pypi.org/help/#invalid-auth)alid-auth for more information.      
          </body>                                                               
         </html>                                                                
ERROR    HTTPError: 403 Forbidden from https://upload.pypi.org/legacy/
         Invalid or non-existent authentication information. See                
        [ https://pypi.org/help/#inv](https://pypi.org/help/#invalid-auth)alid-auth for more information.

This is with no doubt an error because it cannot connect to PyPi. If I run it manually with my PyPi account, everything works fine.

python setup.py sdist bdist_wheel
twine upload --verbose dist/*

I created a github secrets from PyPi and add it in GitHub. I did not touch the end of release.yaml

- name: Build and publish
      env:
        TWINE_USERNAME: __token__
        TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
      run: |
        python setup.py sdist bdist_wheel
        twine upload --verbose dist/*

Am I supposed to modify the token variable ? Thanks !

drbecavin avatar Jun 20 '22 19:06 drbecavin

@drbecavin is your variable called PYPI_API_TOKEN on github secrets?

rochacbruno avatar Jun 20 '22 19:06 rochacbruno

Yes! Now it is in the environments secrets. But I tried in the repository secrets and it did not work.

Capture d’écran 2022-06-20 à 21 58 53

drbecavin avatar Jun 20 '22 20:06 drbecavin

Maybe it is relevant to say that my repository is not hosted on my personal github account , but on my organization account. https://github.com/becavin-lab/checkatlas

drbecavin avatar Jun 20 '22 20:06 drbecavin

@drbecavin Your variable is called PIPY_API_TOKEN, not PYPI_API_TOKEN. This is understandable, as the guide in the README is currently incorrect:

If you want [codecov](https://about.codecov.io/sign-up/) Reports and Automatic Release to [PyPI](https://pypi.org/)
On the new repository settings->secrets add your PIPY_API_TOKEN and CODECOV_TOKEN (get the tokens on respective websites)

@rochacbruno FYI

emptierset avatar Jul 08 '22 09:07 emptierset

Ah !!! Thanks. I changed the name of my secret on github for PYPI_API_TOKEN. But it won't work...

Does it change something that the secret s defne in environment, repository, or organization secrets ?

drbecavin avatar Jul 08 '22 10:07 drbecavin

Thanks @AWConant we need to fix that, maybe that action changed and now required different set of keys, we need to also test that release action.

rochacbruno avatar Jul 08 '22 15:07 rochacbruno

I have the same problem with the python_publish.yml workflow

esimorre avatar Feb 11 '24 19:02 esimorre