For windows native applications which want to target both Azure DevOps and TFS we recommend using the Client Libraries for Azure DevOps and TFS to generate interactive sign in prompts for Azure DevOps users and leverage seemless Windows credential authentication for TFS users.
This buildable sample will walk you through the steps to create a client-side console application which uses Client Libraries - Interactive and Windows Auth to authenticate a Azure DevOps or TFS user and return a list of all projects inside a selected Azure DevOps account or TFS collection.
To run this sample you will need:
From a shell or command line:
git clone https://github.com/Microsoft/vsts-auth-samples.git
Packages: Microsoft.VisualStudio.Services.Client, and Microsoft.TeamFoundation.Core.WebApi have already been installed and configured in the sample, but if you are adding to your own project you will need to install and configure it yourself.
- Navigate to the ADAL C# sample in cloned repo
vsts-auth-samples/DualSupportClientSample/
. - Open the solution file
VstsTfsSample.sln
in Visual Studio 2017. - Use Nuget package restore to ensure you have all dependencies installed.
- Open CS file
Program.cs
and there is a section with input values to change at the top of the class:azureDevOpsOrganizationUrl
- update this with the url to your Azure DevOps/TFS collection, e.g. http://dev.azure.com/organization for Azure DevOps or http://myserver:8080/tfs/DefaultCollection for TFS.
- Build and run the solution. After running you should see an interactive login prompt if you are a Azure DevOps user. If you are a TFS user authentication should happen in the background. After authentication and authorization, a list of all projects inside of your account will be displayed in the console.