Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TF30063: You are not authorized ... programmatic access not working

The code below provided in this answer did work well for a while but now its throwing Microsoft.TeamFoundation.TeamFoundationServerUnauthorizedException: 'TF30063: You are not authorized to access https://{mysite}.visualstudio.com/.' again.

var credentials = new VssClientCredentials();
credentials.PromptType = CredentialPromptType.PromptIfNeeded;

var teamProjects = new TfsTeamProjectCollection(tfsCollectionUri, credentials);
teamProjects.EnsureAuthenticated();         // exception thrown

Q How can I fix this problem?

Update Strange enough,

  1. before executing teamProjects.EnsureAuthenticated(); the debugger reads PromptIfNeeded for credentials.PromptType.
  2. after the exception has been thrown and the debugger has stopped the execution, it reads DoNotPrompt for credentials.PromptType.

Observation The above code works perfectly well in a console application but fails to work in a windows forms application (i.e. it throws an exception).

Q1 How can I make the above code work in a windows forms application?

like image 694
participant Avatar asked Nov 26 '25 09:11

participant


1 Answers

If you execute the code above within a Task (i.e. a separate thread) it just works. If the credentials are not present or stale at the location in the registry (see this answer) a window opens and you can authenticate yourself.

Can anyone explain why this works?

like image 138
participant Avatar answered Nov 27 '25 21:11

participant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!