无法使用PAT从Azure DevOps克隆git [英] Cannot clone git from Azure DevOps using PAT

查看:513
本文介绍了无法使用PAT从Azure DevOps克隆git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从Azure DevOps克隆一个简单的存储库. 操作系统:Ubuntu 18.10

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

我这样做:

  • 转到Azure DevOps
  • 单击我的用户名右上角
  • 转到安全标签
  • 创建具有所有范围的PAT(确保没有范围) 问题)
  • 将PAT复制到剪贴板
  • 将PAT粘贴到其他位置以确认PAT已正确复制(我知道...不安全,但这不在此问题范围内)
  • 转到我的控制台
  • 问题:git clone https://myorganization.visualstudio.com/myproject/_git/myrepo/
  • 我输入用户名和密码(PAT)
  • 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)

我一直从Git收到此消息: fatal: Authentication failed for 'https://myorganization.visualstudio.com/myproject/_git/myrepo/'

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:token@myorganization.visualstudio.com/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)

  • 试图在git命令中使用http.extraHeader,标题为

  • Tried to use the http.extraHeader in the git command with the header being

    Authorization: Bearer PAT

  • 试图使用VSCode客户端.它可以自行生成PAT,但仍无法进行身份验证和克隆.
  • 试图使用Rider VSTS客户端.它可以自行生成PAT,但仍无法进行身份验证和克隆.
  • 试图在Linux上使用git凭证管理器.它会提示代码,当我们在浏览器中进行身份验证时,它将成功生成PAT.尽管如此,之后仍然无法进行身份验证.
  • 任何线索为什么这不起作用?

    Any clue why this is not working?

    推荐答案

    我遇到了同样的问题,并且花了相当长的时间寻找解决方案.我终于遇到了 Martinius79 的评论部分中的解决方案.

    I've experienced the same issue, and spent quite a while searching for a solution. I finally came across this post which contained a solution in the comments section by Martinius79.

    简而言之,需要通过git http.extraheaders传递编码为base64的用户名和PAT,以便进行身份验证.

    In short, it was required to pass the username and PAT, encoded as base64, through git http.extraheaders in order for it to authenticate.

    100%归功于原始作者,只是在此处包括它以帮助其他人找到它:

    100% Credit to the original author, just including it here to assist others in locating it:

    示例: git -c http.extraheader =授权:基本TXlHaXRTeW5jVXNlcjo2bHFqNXJkcHEzdXBxZWVmd2o3bDduZXN5NTR3d3gxNHFobDVlanl5NTVkb2g0M3d4YzRh"克隆/<地址///tfs/Collection/Project/_git/RepoName

    Example: git -c http.extraheader="AUTHORIZATION: Basic TXlHaXRTeW5jVXNlcjo2bHFqNXJkcHEzdXBxZWVmd2o3bDduZXN5NTR3d3gxNHFobDVlanl5NTVkb2g0M3d4YzRh" clone https://tfs.address/tfs/Collection/Project/_git/RepoName

    已使用的基本令牌BASE64编码为:TXlHaXRTeW5jVXNlcjo2bHFqNXJkcHEzdXBxZWVmd2o3bDduZXN5NTR3d3gxNHFobDVlanl5NTVkb2g0M3d4YzRh

    Used basic token BASE64 encoded: TXlHaXRTeW5jVXNlcjo2bHFqNXJkcHEzdXBxZWVmd2o3bDduZXN5NTR3d3gxNHFobDVlanl5NTVkb2g0M3d4YzRh

    基本令牌BASE64解码:MyGitSyncUser:6lqj5rdpq3upqeefwj7l7nesy54wwx14qhl5ejyy55doh43wxc4a

    Basic Token BASE64 decoded: MyGitSyncUser:6lqj5rdpq3upqeefwj7l7nesy54wwx14qhl5ejyy55doh43wxc4a

    令牌是根据以下内容构造的: 在此示例中: 虚拟用户名:MyGitSyncUser 二手PAT:6lqj5rdpq3upqeefwj7l7nesy54wwx14qhl5ejyy55doh43wxc4a

    Token is constructed from : In this example: Fictional user name: MyGitSyncUser Used PAT: 6lqj5rdpq3upqeefwj7l7nesy54wwx14qhl5ejyy55doh43wxc4a

    我希望这会有所帮助!

    这篇关于无法使用PAT从Azure DevOps克隆git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆