问题
I'm aware of alternate credentials (Authenticating to hosted TFS: TF30063: You are not authorized to access .visualstudio.com) but I need users to be prompted for the credentials when connecting to visualstudio.com.
Similar in spirit to the code below, which does not work
var aTeamProjects = new TfsTeamProjectCollection(m_oTfsCollectionUri);
aTeamProjects.ClientCredentials.PromptType = CredentialPromptType.PromptIfNeeded;
aTeamProjects.Authenticate();
In the code above the Authenticate
-request results in TF30063: You are not authorized to access .visualstudio.com.
回答1:
The solution is working on a new project with the code below. Then provide the credentials if it is asked when running an app.
var credentials = new VssClientCredentials();
credentials.PromptType = CredentialPromptType.PromptIfNeeded;
var aTeamProjects = new TfsTeamProjectCollection(m_oTfsCollectionUri, credentials);
aTeamProjects.EnsureAuthenticated();
来源:https://stackoverflow.com/questions/46075533/error-tf30063-force-prompt-for-credentials-when-connecting-programmatically-to