Error 403 when trying authentication with PAT in github

Viewed 940

I have 2FA (two-Factor Authentication) enabled on github, and I can't push to repository (I have Gitbash for Windows). I have PAT (Public Access Token) for public access and repository where I'm trying to push is public. I tried to update gitbash, as suggested here: Logon failed use ctr + c to cancel..., but now when I try git push origin dev (it doesn't exist on repo but should be created after this command) it's not doing anything until I press ctrl+c and cancel action. When I'm trying to push from IDE (Android studio) it's same as before update; I enter username or email and in field for password PAT, and I get error 403.

Edit

I was able to git push origin dev when I uninstalled git and installed again (before that I updated old version, but something did not work, as I mentioned). But I didn't use PAT(I tried). Git shows me something like:

Select an authentication method for 'https://github.com/':
  1. Web browser (default)
  2. Personal access token

Second option don't works for me, but first is working in this case, because I'm using Credential Manager and I see new branch when I go to github.

This is public repo and my PAT have public access, I allowed one user to collaborate in repo. Is there problem? When I was creating PAT I didn't check anything because only options were access to private repos, following other users, gists, etc. Should my token work in this case and why?

2 Answers

Using the standalone and cross-platform "GCM" (Git Credential Manager) indirectly solved this problem for me (on a Windows 1O platform)

I installed it from this resource : https://github.com/microsoft/Git-Credential-Manager-Core/releases/tag/v2.0.498

(https://github.com/microsoft/Git-Credential-Manager-Core)

Once it is installed, the first push operation (or pull) displays a prompt allowing to reach the remote GitHub. It didn't work well with the Personal Access Token, but this tool also allows to open the GitHub HTML page, by providing the "classic" username and password. It apparently stores the credentials in a cache. Commits and pushes both work with the Bash console and TortoiseGit. I'm not sure what happens when the token expires though...

If you are using a PAT generated some times ago, check if you have to regenerate them after their Token authentication requirements for Git operations published last Dec. 2020.

Note that the Authentication token format has been updated, and you might have to delete your current PAT, and regenerate it, in order for said token to be compliant with the new format:

  • The character set changed from [a-f0-9] to [A-Za-z0-9_]
  • The format now includes a prefix for each token type:
    ghp_ for Personal Access Tokens
Related