How do I authenticate with Visual Studio Team Services using the new basic authentication using the .Net Windows service?

I am trying to access https://visualstudio.com (formerly known as https://tfs.visualstudio.com , http://www.tfspreview.com ) from my .NET written Windows service.

I want to use the new basic authentication, but I could not find a way to do this.

I found many links to the Team Foundation Service Update blog post on August 27th , but it uses the Team Explorer Everywhere Java client for TFS.

Is there a new version of the TFS.NET object model to support basic authentication?

By the way, I sequentially logged into the service account. This answer was very helpful.

+8
c # tfs vsts basic-authentication
source share
2 answers

First of all, your computer must have at least Visual Studio 2012 Update 1 . It includes an updated assembly of Microsoft.TeamFoundation.Client.dll with the BasicAuthCredential class.

Here is the code for this, from the Buck Blog Post How to Connect to the Team Foundation Service .

 using System; using System.Net; using Microsoft.TeamFoundation.Client; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { NetworkCredential netCred = new NetworkCredential( "yourbasicauthusername@live.com", "yourbasicauthpassword"); BasicAuthCredential basicCred = new BasicAuthCredential(netCred); TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred); tfsCred.AllowInteractive = false; TfsTeamProjectCollection tpc = new TfsTeamProjectCollection( new Uri("https://YourAccountName.visualstudio.com/DefaultCollection"), tfsCred); tpc.Authenticate(); Console.WriteLine(tpc.InstanceId); } } } 
+12
source share

There are some updates for authentication. For .NET applications, we recommend using the VSTS client libraries . Another option is to use Azure Active Directory Libraries (ADAL). For more information and samples, check the VSTS authentication documentation .

0
source share

All Articles