Forums

Authentication with Github failed

Hi,

I'm trying to link bash on pythonanywhere with my Github account, according to the Djangogirls tutorial.

I get the following error message when running

pa_autoconfigure_django.py --python=3.8 https://github.com/<Username>/<RepoName>.git:

< Running API sanity checks > \ ~<:>>>>>>>>> Cloning into '/home/Suqui/suqui.pythonanywhere.com'... Username for 'https://github.com': Username Password for 'https://Username@github.com': remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/Username/RepoName.git/' Traceback (most recent call last): File "/home/Suqui/.local/bin/pa_autoconfigure_django.py", line 47, in <module> main(arguments['<git-repo-url>'], arguments['--domain'], arguments['--python'], nuke=arguments.get('--nuke')) File "/home/Suqui/.local/bin/pa_autoconfigure_django.py", line 30, in main project.download_repo(repo_url, nuke=nuke), File "/home/Suqui/.local/lib/python3.8/site-packages/pythonanywhere/django_project.py", line 18, in download_repo subprocess.check_call(['git', 'clone', repo, str(self.project_path)]) File "/usr/lib/python3.8/subprocess.py", line 364, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['git', 'clone', 'https://github.com/UserName/RepoName.git', '/home/Suqui/suqui.pythonanywhere.com']' returned non-zero exit status 128.

Username and password are definitively correct, I've tried various times and double - and triple checked.

Thanks in advance! :)

What happens when you try to git clone that repo in a Bash console?

Similar traceback:

Cloning into 'SuquiWrites'... Username for 'https://github.com': Username Password for 'https://Username@github.com': remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/Username/SuquiWrites.git/'

It looks like you didn't change placeholders for the username and repo name -- in the original command you should put in place of <Username> your github account name and in the place of <RepoName> -- name of the repo you want to clone. But I'd suggest you just go to your github account and copy the link which will be shown to you after clicking on the green "Code" button in the right upper corner above the files list.

No, no, I did do that. I just didn't want to post the information here, so I edited it out. But the call was done correctly. :)

Oh, it wasn't explicit in your post so I wanted to eliminate this possibility (it happens, really). Does it work with the same credentials when you do this on your local machine?

Yes, on the local it works fine. Mind, I had the same problem on my old machine locally to start with.

OK -- just to be sure: are you using exactly the same command to clone the repo on your local machines and on PythonAnywhere? (Now I want to exclude that there are no differences between machines like using ssh over https, or having credentials predefined in a config file etc.).

yes, exactly the same commands. I've also tried with both ssh and https and neither works.

This article seems to sugegst that you'd get that error if you had 2FA configured for your account and have not set up a personal access token.

Yes, this worked! Thanks so much. :)

Excellent, glad we could help!

Hi, I've generated PAT but bash shows me this message Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. what should I do?

What do you try to do?

Take a look at https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/

Please what command can I use to clone a repository in my Bash Console? I'm getting the following errors:

16:39 ~ $ git clone https://github.com/<Username>/Repo Cloning into 'Portfolio'... Username for 'https://github.com': Username Password for 'https://Repo@github.com': remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information. fatal: unable to access 'https://github.com/Username/Repo/': The requested URL returned error: 403

Github changed their authentication requirements. You need to use a personal access token to use your repository instead of a password. Follow the link in the error message for instructions on how to do that.

Do you by chance have a PythonAnywhere specific link for how to create and use personal access tokens? I'm not a new user and I am struggling mightily to figure out how to access my code.

The biggest issue I'm facing right now is that I can't paste the token, so I have to type it out by hand every single time. Is that how it's supposed to work?

Nevermind! It looks like I can paste in the access token, which should work fine for me now. Sorry for the necro!

No problem -- glad you worked it out!