0

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.

participant
  • 2,923
  • 2
  • 23
  • 40

1 Answers1

0

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();
participant
  • 2,923
  • 2
  • 23
  • 40
starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • 2
    Without ever being prompted for anything I kep getting: Microsoft.TeamFoundation.TeamFoundationServerUnauthorizedException: TF30063: You are not authorized to access vs.com ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized. – John Grabanski Jul 11 '18 at 20:38
  • @JohnGrabanski having the same problem with `VssClientCredentials` with 15.0 TFS client API. Have you found the reason ? [there is credentials prompt bug described](https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/client-libraries/samples?view=azure-devops#visual-studio-sign-in-prompt-microsoft-account-or-azure-active-directory-backed-for-soap-services) – oleksa Apr 25 '19 at 07:46