1

I'm using a personal access token to access Github from the command line, in place of a password when prompted for my username and password. If I make a new access token, it works just fine in place of my password the first time, but if I try to use it again, I get this error:

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for <my-repo>

The only way I have been able to use Github from the command line has been to make a new personal access token every single time I need to use a password.

I have tried different expiration dates, but nothing seems to change this behavior. I also have experimented with the new fine-grained tokens, but I need to be able to access private repositories that I do not own (through Github classroom) and as far as I can tell the fine-grained tokens don't allow me to do that without being provided with a token by the admin, which isn't an option for me.

I have the same issue across multiple platforms, so I don't think it has to do with my local environment.

nelazar
  • 19
  • 3
  • "The only way I have been able to use Github from the command line has been to make a new personal access token every single time I need to use a password" No one else is having this problem — I use the same PAT at intervals for many months — but consider switching to SSH. – matt Nov 22 '22 at 00:49

2 Answers2

1

That PAT is being revoked for any reason and you can likely find the answer in the security log.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • Usually if they revoke a PAT they tell you. – matt Nov 22 '22 at 01:44
  • Well, there's no other logical explanation and only the security logs or token page could tell. Because the error message provided doesn't help at all, and if the token works once only, what else should be the reason? It could also be a token which expires soon, but that's it. – Martin Zeitler Nov 22 '22 at 13:57
  • @matt In my case they did not tell me, and looking at the security log was the only way to see it – hayden.mumm Mar 22 '23 at 20:42
  • @hayden.mumm In all truth I forget how I worked out when mine had been revoked, so I believe you! – matt Mar 22 '23 at 20:56
0

It is possible your old password (not token) is currently stored in your credential helper:

git config --global credential.helper

If you get a value (say xxx), check what if your password is stored there:

printf "host=github.com\nprotocol=https" | git-credential-xxx get

If you see the old password, remove it, and store a new PAT (token).

printf "host=github.com\nprotocol=https\nusername=yourAccount" | git-credential-xxx erase

printf "host=github.com\nprotocol=https\nusername=yourAccount\npassword=yourToken" | git-credential-xxx store

For each commands, replace xxx by the value of the credential helper.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • There is nothing stored in my credential helper. I have the same problem on any system I use, so I don't think it is anything about my local environment. I'll update the question to include this. – nelazar Nov 22 '22 at 00:20
  • @nelazar Still, try and create a new PAT, and store it as described in this answer, to see if the issue persists. – VonC Nov 22 '22 at 06:47