Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

authentication - Cannot clone git from Azure DevOps using PAT

I cannot clone a simple repository from Azure DevOps. OS: Ubuntu 18.10

I do this:

  • Got to Azure DevOps
  • Click on the top right corner on my user name
  • Go to the security tab
  • Create a PAT with all the scope (to be sure there is no scope problem)
  • Copy the PAT to the clipboard
  • Paste the PAT somewhere else to confirm the PAT has been copied correctly (I know... not safe but that is out of the scope of this question)
  • Go to my console
  • Issue: git clone https://myorganization.visualstudio.com/myproject/_git/myrepo/
  • I enter the user name and the password (the PAT)

I keep getting this message from Git: fatal: Authentication failed for 'https://myorganization.visualstudio.com/myproject/_git/myrepo/'

I was reading the solutions of other people but none worked for me. I also tried this:

  • Pass the token in the form https://usename:[email protected]/myproject/_git/myrepo/ I am really surprised people say this worked... for my git complains because believes the : means the port.
  • Tried to activate/deactivate credential manager of git * Tried on Windows and Ubuntu.
  • Tried to activate and deactivate the simple credentials.
  • Tried with the simple credentials, i.e. username + password.
  • Tried to put my user name in https://username@....
  • Tried to use SSH
  • Tried to use the http.extraHeader in the git command with the header being
    Authorization: Basic Base64Encoded(uname:PAT)
  • Tried to use the http.extraHeader in the git command with the header being
    Authorization: Bearer PAT
  • Tried to use the VSCode client. It generates the PAT by itself but still cannot authenticate and clone.
  • Tried to use the Rider VSTS client. It generates the PAT by itself but still cannot authenticate and clone.
  • Tried to use the git credentials manager for Linux. It promps the Code and when we authenticate in the browser, it generates a PAT successfully. Still, after that cannot authenticate.

Any clue why this is not working?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have had success using PAT like this;

  1. copy clone url for your repository e.g. git clone https://<domain>.visualstudio.com/<domain>/_git/<domain>
  2. After you have copied you PAT use as;

git clone https://<PAT>@<domain>.visualstudio.com/<domain>/_git/<domain>

No Username nor password should be required as the PAT should suffice.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...