How can i provide credentials to TfsTeamProjectCollectionFactory.GetTeamProjectCollection
?
I am trying to develop my own WCF Service from witch I will make the request to TFS
I need this WCF service because I would like to manage my TFS files from mobile in witch I cannot use Microsoft.TeamFoundation.* dll
I have been trying this way
Uri tpcAddress= new Uri("https://myserver.visualstudio.com/DefaultCollection");
TfsConnection tfsc = new TfsConfigurationServer(tpcAddress,
new NetworkCredential("[email protected]", "password"));
TfsWebClient wc = new TfsWebClient(tfsc);
tfsc.Connect(ConnectOptions.IncludeServices);
Second try using Custom class derived from ICredentialsProvider
ICredentialsProvider prov = new myCredentials();
var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpcAddress, prov);
tpc.EnsureAuthenticated();
tpc.Authenticate();
public class myCredentials : ICredentialsProvider
{
public ICredentials GetCredentials(Uri uri, ICredentials failedCredentials)
{
return new NetworkCredential("[email protected]", "password");
}
public void NotifyCredentialsAuthenticated(Uri uri)
{
}
}
But it works only in my machine since I am logged in to tfs.
To avoid being prompted for logging in with your Live ID or having to be already signed in, you need to enable Alternate Logon Credentials and use it with your service.
This blog post tells you how:
Note that you need to have VS 2012 Update 1 installed to have this feature.
Hope this helps.