gpt4 book ai didi

c# - TF30063 : You are not authorized to access https://test. visualstudio.com/DefaultCollection

转载 作者:太空宇宙 更新时间:2023-11-03 10:48:14 29 4
gpt4 key购买 nike

我正在尝试连接到 TFS 并使用以下代码对用户进行身份验证。但我收到错误:

TF30063: You are not authorized to access https://test.visualstudio.com/DefaultCollection.

var netCred = new NetworkCredential("test@live.in", "password");
var windowsCred = new WindowsCredential(netCred);
var tfsCred = new TfsClientCredentials(windowsCred);
tfsCred.AllowInteractive = false;
var tpc = new TfsTeamProjectCollection(tfsUri, tfsCred);
tpc.Authenticate();

当我在代码下方运行时,它会提示我必须输入凭据的窗口。

var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("https://test.visualstudio.com/DefaultCollection"));
var store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

此应用程序将由外部人员使用,我需要静默登录到 TFS。

我看到了下面的解决方案,但我不能要求每个用户都这样做。

http://blogs.msdn.com/b/buckh/archive/2013/01/07/how-to-connect-to-tf-service-without-a-prompt-for-liveid-credentials.aspx

请给我一些解决方案。

最佳答案

Your users will have to log on using the Live ID/MSA一次,他们可以选中保存凭据的框,这样他们以后就不会收到提示。 future Visual Studio Online 可能会转向使用 Azure Active Diectory/Azure Access Control Services 的解决方案,这将允许您使用其他凭据类型,现在您需要让您的用户启用基本身份验证或让他们进行身份验证到 VSO 一次并让他们选中“保存凭据”复选框,这样他们以后就不会收到提示。

Uri collectionUri = new Uri("https://youraccount.visualstudio.com:443/defaultcollection");
UICredentialsProvider credentialProvider = new UICredentialsProvider();
var tfs = TfsTeamProjectCollectionFactory
.GetTeamProjectCollection(collectionUri, new UICredentialsProvider());
tfs.EnsureAuthenticated();

如果您想使用 Basic Credentials 进行连接,您还可以使用此代码(在为您要使用的帐户启用 Basic Credentials 之后):

NetworkCredential netCred = new NetworkCredential(
"someone@yahoo.com",
"password");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;

TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(
new Uri("https://YourAcct.visualstudio.com/DefaultCollection"),
tfsCred);

tpc.Authenticate();

关于c# - TF30063 : You are not authorized to access https://test. visualstudio.com/DefaultCollection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22594064/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com