Home > Software engineering >  Re-enable VSCode GitHub authentication
Re-enable VSCode GitHub authentication

Time:11-18

Absolutely for no reason that I may think of, vs code built in git scm stopped working , only returning authentication failed, not only in vscode, but also in terminal. A weird thing is that last night it was working fine. Just to wonder today its not working anymore.

  • I use ubuntu 21.04, and I have 2fa enabled in github.
  • I tried to create personal access token but i cant find anywhere to put it for git scm in vscode to work correctly across all repositories without exposing it.

By VSCode git-scm stopped working I mean:-

  • Can't pull/push to remote repository using the built in git extension in VSCode
  • Can't issue clone command for private repositories

I want a way to re-enable the extension functionalities, without using email and password or appending access token before the remote url path as specified here

PS: I have co-pilot git extension enabled and its authenticated properly in git (properly working)

CodePudding user response:

Check first if your remote URL is an HTTPS one (in command-line: once this is working there, you can switch back to VSCode):

cd /path/to/repo
git remote -v

If HTTPS, check what credential helper is used to cache your credentials. An old password might be cached, which is no longer valid, since now only PAT (Personnal Access Token) are allowed (following the Aug. 2021 policy change).

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

(replace xxx by the output of git config --global credential.helper)

If this is the wrong "password" (ie., not your current token), erase the old one and store the new one.

printf "host=github.com\nprotocol=https" | git-credential-xxx erase
printf "host=github.com\nprotocol=https\nusername=MyGitHubUserAccount\npassword=yyy" | git-credential-xxx store

CodePudding user response:

Having the same/similar issue with accessing github through vscode using Ubuntu. The remote URL is https and I've been using tokens for months now and it suddenly stopped working. I was not able to push a commit through VScode. I was able to push the commit through a separate terminal session using CLI so I know the token is still valid. I was also able to pull this same commit on another machine so everything seems to be working correctly outside of vscode. Below is the message output from vscode:

git pull --tags origin dev

remote: Repository not found.

fatal: Authentication failed for 'https://github.com/BrianT71/fantasyfootball.git/'

I'm signed into github through VScode and I even logged out/logged in again to see if that fixed it. Nope.

Don't know if this matters but it's a private repository.

Update: VSCode updated a few days ago to 1.62.2-1636665017 This update would appear to be trigger for the problem.

  • Related