使用TFS个人访问令牌克隆Git Repo [英] Cloning Git Repo using TFS Personal Access Token

查看:98
本文介绍了使用TFS个人访问令牌克隆Git Repo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试以编程方式克隆git存储库。我的ASP.NET MVC应用程序正在创建和启动一个进程。处理进程的代码可以正常工作,但是当尝试使用TFS内部PAT来克隆
git存储库时,身份验证失败。我无法使用NTLM或要求用户输入凭据。我可以确认我的C#代码处理创建进程以编程方式使用git bash shell,因为我在本地计算机上没有问题但在IIS上生产时出现了问题。
我尝试了以下两种方法。



Method 1 :git clone http:// anyusername :PAT @ tfs2017:8080 / tfs / DefaultCollection / _git / Git%20Repository



PAT @ tfs2017  是我为我的用户生成的令牌。我已尝试
在base64中对其进行编码。


< p style ="padding-right:0px;字体大小:15像素;行高:继承; font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;垂直对齐:基线;明确:两者;颜色:#242729">
方法2 :正如MS社交论坛上的人所建议的那样。



git -c http.extraheader =" AUTHORIZATION:bearer { base64encodedPAT }"
clone { url }

解决方案


我可以重现你的情况。我已经尝试了以下所有命令,但没有一个可以工作:


git clone http:// anyusername:PAT @ tfs2017:8080 / tfs / DefaultCollection / _git / Git%20存储库


git clone http://:PAT @ tfs2017:8080 / tfs / DefaultCollection / _git / Git%20Repository


git clone http:// PAT @ tfs2017:8080 / tfs / DefaultCollection / _git / Git%20Repository (这将在git凭证管理器中输入用户名)


git -c http.extraheader =" AUTHORIZATION:bearer {base64encodedPAT}" clone {url}



作为替代方案,您可以使用以下命令。使用此命令,将提示Credential Manager,然后您可以键入空用户名并使用PAT作为密码。


git clone http:// tfs2017:8080 / tfs / DefaultCollection / _git / Git%20Repository


最好的问候,





I am trying to programmatically clone a git repository. My ASP.NET MVC application is creating and starting a process. The code to handle the processes works correctly however the authentication is failing when trying to use a TFS on premise PAT to clone a git repository. I cannot use NTLM or require the user to enter credentials. I can confirm my C# code handling creating processes to use the git bash shell programmatically works as I have no issue on my local machine but in production on IIS the issue arises. I have tried the following two methods.

Method 1: git clone http://anyusername:PAT@tfs2017:8080/tfs/DefaultCollection/_git/Git%20Repository

PAT@tfs2017 is the token I have generated for my user. I have tried to encode it in base64 as well.

Method 2: As suggested by a person on a MS social forum.

git -c http.extraheader="AUTHORIZATION:bearer {base64encodedPAT}" clone {url}

解决方案

Hi,

I could reproduce your situations. I have tried all following commands, but none could work:

git clone http://anyusername:PAT@tfs2017:8080/tfs/DefaultCollection/_git/Git%20Repository

git clone http://:PAT@tfs2017:8080/tfs/DefaultCollection/_git/Git%20Repository

git clone http://PAT@tfs2017:8080/tfs/DefaultCollection/_git/Git%20Repository (This will have pat in the username in git credential manager)

git -c http.extraheader="AUTHORIZATION:bearer {base64encodedPAT}" clone {url}

As an alternative, you can use the command below. With this command, the Credential Manager will be prompted, then you can type empty user name and use the PAT as password.

git clone http://tfs2017:8080/tfs/DefaultCollection/_git/Git%20Repository

Best regards,


这篇关于使用TFS个人访问令牌克隆Git Repo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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