denpal
denpal

Reputation: 3

Connecting to TFS programatically throws Unauthorized error, unless visual studio is connected to TFS Project. How can i fix this?

I'm currently working in a WinForms app and using different .net client library to connect to TFS/Azure DevOps:

Microsoft.TeamFoundation.Client; Microsoft.VisualStudio.Services.Common;

and my IDE is Visual Studio 2015.

After trying to connect to TFS/Azure DevOps through diffrent methodes like:

1) Default Credentials

configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri);

or

var tpc = new TfsConfigurationServer(tfsUri);
tpc.Authenticate();

2) VssCredentials with alternate credentails activated

var winCred = new Microsoft.VisualStudio.Services.Common.WindowsCredential(
var creds = new VssCredentials(winCred);
tfsCredential.AllowInteractive = false;

var tpc = new TfsConfigurationServer(tfsUri);
tpc.Authenticate();

I noticed that only TFS Sites that were already connected to my Visual Studio IDE connected properly. It didnt matter if I added credentials or not!

~ What seams to be the problem here?

~ How can I fix it?

~ What changes when I connect my IDE to TFS that allows me afterwards to connect to TFS programatically?

Upvotes: 0

Views: 326

Answers (1)

Jayendran
Jayendran

Reputation: 10920

This is more likely the credentials were stored in your Credential Manager.

You should try to remove those. Refer this blog

Also you can refer this SO to remove the cached credentials from your Visual studio.

Upvotes: 1

Related Questions