The Azure Active Directory Authentication Library (ADAL) enables client application developers to authenticate cloud users and obtain access tokens for API usage.
This buildable sample will walk you through the steps to create a client-side console application which uses ADAL to authenticate a user via an interactive prompt and return a list of all projects inside a selected VSTS account.
From a shell or command line:
git clone https://github.com/Microsoft/vsts-auth-samples.git
Package: Microsoft.Identity.Model.Clients.ActiveDirectory has 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/ManagedClientConsoleAppSample/ - Use Nuget package restore to ensure you have all dependencies installed
- Open the solution file
ManagedClientConsoleAppSample.csprojin Visual Studio 2017 - Open CS file
Program.csand there is a section with input values to change at the top of the class:vstsCollectionUrl- Mutable value. This is the url to your VSTS/TFS collection, e.g. http://myaccount.visualstudio.com for VSTS or http://myserver:8080/tfs/DefaultCollection for TFS.
- Build and run solution. After running you should see a list of all projects inside of myaccount.