1

I know there's been questions about this previously, but I am still getting an annoying error when trying to push a repository:

git push --set-upstream origin main
Username for 'https://github.com': xxx
Password for 'https://xxx@github.com':

After I enter my personal access token, it errors out with:

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: Authentication failed for 'https://github.com/sahwa/thesis.git/'

I have created an access token and been using is successfully for a while, but git will still return the above error occasionally for no apparent reason. I am using git version 2.32.0.

I should add that a) this is a new personal access token that isn't expired and b) has all of the correct scopes selected.

Does anyone know how to resolve this?

user438383
  • 5,716
  • 8
  • 28
  • 43
  • You need to specify the token when it asks for the password. Have you tried that? – Paolo Nov 24 '21 at 19:02
  • @Paolo yes, and it has worked many times previously, but it apparently randomly decides I'm still using a password. – user438383 Nov 24 '21 at 19:03
  • So ... this same token usually works, but sometimes fails? That suggests a problem not on your end, but on theirs (GitHub's). This kind of thing can happen with load balancers, if there is one rogue system that rarely gets used that rejects incorrectly. When it does get used, you get the rejection. When (as usual) it doesn't, everything works. If that's actually the case, only they can fix it; whether (and if so, how) you can help them track it down depends on variables at their end. – torek Nov 26 '21 at 00:01

2 Answers2

2

The issue is likely your remote, which is set automatically when you git clone!

You can see and change the remote to the git protocol, rather than https as

git remote -v  # display
git remote set-url origin git@github.com:User/UserRepo.git
ti7
  • 16,375
  • 6
  • 40
  • 68
-1

Does the personal access token have any expiration or set to lifetime? Assuming that its set to life time this is the proper method to login using personal access token

git push https://<GITHUB_ACCESS_TOKEN>@github.com/<GITHUB_USERNAME>/<REPOSITORY_NAME>.git

better way would be to sign into a git client like in IntelliJ or VScode extension and let it handle the reauthentication and push