GIT Fatal error: Authentication failed in Visual S

2020-03-24 07:13发布

问题:

As of today I'm getting errors when trying to use git commands with my repository in Azure-DevOps. The repositories sit in a project on DevOps that I can access with the same account and shows no sign of any recent changes to it. The steps I can take to reproduce it is:

  1. Open the command prompt and enter git fetch
  2. A window appears prompting for a login
  3. I click the account
  4. No password is prompted, but an e-mail arrives that a PAT has been created
  5. The command prompt yields an error

Error:

fatal: Authentication failed for `<link to repository>`

Things I've tried so far:

  • Restarting PC
  • Signing out and in on Visual Studio
  • Removing the .IdentityService folder
  • Removing and installing GIT
  • Removing and installing GIT For Windows in the Visual Studio Installer
  • Removing the cache folder %LOCALAPPDATA%\Microsoft\Team Foundation\7.0\Cache
  • Removing the cache folder %LOCALAPPDATA%\Microsoft\Team Foundation\8.0\Cache
  • Removing GIT and VS keys from the Credential Manager
  • Quite a few other things 'fixes' found online that did not solve my issue

Currently running:

  • GIT 2.21.0-64 bit
  • Visual Studio 2019

Edit:

I've attempted using Visual Studio Code with the Azure Repos 1.149.2 extension and get the same error. It yields me the Microsoft page to enter my code for device login which it grants, but using git commands give me the same error messages.

I've also had my profile removed from the Azure DevOps environment and re-added without success.

回答1:

Try and check the value of git config credential.helper.

If you see "manager", open the Windows Credentials Manager, and put as a password the PAT -- the Personal Access Token created -- (while keeping your regular login, associated to the remote URL)

Then try again, and see if the issue persists.



回答2:

To force the Git credential Manager to stop interfering, you can add the following to your global git config:

[credential]
    helper = 

This effectively turns off any credential manager. In Azure DevOps you can then configure a set of Git Credentials or a Personal Access Token and use that to connect directly.

It doesn't explain the problems you're experiencing. Given that your account seems to be Machine Bound and an AAD account a lot of things can be in play. This includes AAD Home-Realm Discovery and Single Sign-on and Azure Active Directory Guest accounts.

Another possible problem is your Windows Credential Store which has multiple locations where Azure DevOps and Git credentials are stored. And finally the account used to sign-in to Visual Studio 2019 to retrieve its license may be playing up.

With the information you've provided it's neigh impossible for us to help you resolve the issues without looking over your shoulder. I'd almost suggest filing an Azure support request if you have them available so an engineer can look with you.

Optionally run

git-credential-manager.exe erase

And pass in the following data

protocol=https
host=dev.azure.com
path=/jessehouwing/vsts-extensions/_git/vsts-github-tasks
{newline}

To tell git to delete the credentials stored for your account