c# VssBasicCredential with Username & Password

Viewed 429

i am trying to create a TfsTeamProjectCollection() Object with username & password

this is my attempt:

NetworkCredential netCred = new NetworkCredential(username, password), domain);
VssBasicCredential credentials = new VssBasicCredential(netCred);

i use this authentication inside a webservice which is called from an other application i get no error when i call the web service and use the TfsTeamProjectCollection object whatsoever.

if i use an AccessToken created with the user i try to use for authentication it works if i use it like this:

VssBasicCredential credentials = new VssBasicCredential(string.Empty, accessToken);

am i missing something? or is this not possible to do. also maybe it is importnat that i use https for this webservice

1 Answers

If you want connect to TFS collection with Username & Password. You can have a try using below WindowsCredential object:

NetworkCredential netCred = new NetworkCredential(username, password, domain);
               
Microsoft.VisualStudio.Services.Common.WindowsCredential winCred = new Microsoft.VisualStudio.Services.Common.WindowsCredential(netCred);

TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(new Uri(collectionUrl), winCred);

Or you can just use the NetworkCredential object:

NetworkCredential netCred = new NetworkCredential(username, password, domain);
                      
TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(new Uri(collectionUrl), netCred);
Related