2017-09-06 24 views
0

我知道备用凭据(Authenticating to hosted TFS: TF30063: You are not authorized to access .visualstudio.com),但我需要在连接到visualstudio.com时提示用户输入凭据。错误TF30063:以编程方式连接到visualstudio.com时强制提示输入凭据

的精神,下面的代码,它不工作

var aTeamProjects = new TfsTeamProjectCollection(m_oTfsCollectionUri); 
aTeamProjects.ClientCredentials.PromptType = CredentialPromptType.PromptIfNeeded; 
aTeamProjects.Authenticate(); 

在上面TF30063的Authenticate - 请求结果代码类似:您没有权限访问.visualstudio.com。

+0

它是一个客户端应用程序(例如Windows窗体,控制台应用程序)或Web应用程序?试试var c = new VssClientCredentials(); TfsTeamProjectCollection _tfs = new TfsTeamProjectCollection(m_oTfsCollectionUri,c); _ tfs.EnsureAuthenticated(); –

+0

@ starain-MSFT我已添加更新。 – participant

+0

您可以在另一台机器上重现此问题吗? –

回答

1

解决方案正在开发一个新项目,其代码如下。然后在运行应用程序时询问是否提供了凭据。

var credentials = new VssClientCredentials(); 
credentials.PromptType = CredentialPromptType.PromptIfNeeded; 
var aTeamProjects = new TfsTeamProjectCollection(m_oTfsCollectionUri, credentials); 
aTeamProjects.EnsureAuthenticated(); 
相关问题