You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The [Azure Active Directory Authentication Library (ADAL)](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-authentication-libraries) enables client application developers to authenticate cloud users and obtain access tokens for API usage.
4
+
5
+
## Sample Application
6
+
7
+
This buildable sample will walk you through the steps to create single page javascript application which uses ADAL to authenticate a user via an interactive prompt and all VSTS known information associated with the signed in identity.
8
+
9
+
To run this sample you will need:
10
+
* Http-server. You can download [NPM http server](https://www.npmjs.com/package/http-server) if you need one.
11
+
* An Azure Active Directory (AAD) tenant. If you do not have one, follow these [steps to set up an AAD](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-howto-tenant)
12
+
* A user account in your AAD tenant
13
+
* A VSTS account backed by your AAD tenant where your user account has access. If you have an existing VSTS account not connected to your AAD tenant follow these [steps to connect you AAD tenant to your VSTS account](https://www.visualstudio.com/en-us/docs/setup-admin/team-services/manage-organization-access-for-your-account-vs)
14
+
15
+
## Step 1: Clone or download vsts-auth-samples repository
## Step 2: Register the sample application with you Azure Active Directory tenant
23
+
24
+
1. Sign in to the [Azure Portal](https://portal.azure.com).
25
+
2. On the top bar, click on your account and under the Directory list, choose the Active Directory tenant where you wish to register your application.
26
+
3. On the left hand navigation menu, select `Azure Active Directory`.
27
+
4. Click on `App registrations` and select `New application regirstation` from the top bar.
28
+
5. Enter a `name` for you application, ex. "Adal JS sample", choose `Web app/API` for `application type`, and enter `http://localhost:8080` for the `Redirect URI`. Finally click `create` at the bottom of the screen.
29
+
6. Save the `Application ID` from your new application registration. You will need it later in this sample.
30
+
7. Grant Permissions for VSTS. Click `Required permissions` -> `add` -> `1 Select an API` -> type in and select `Microsoft Visual Studio Team Services` -> check the box for `Have full access to...` -> click `Save` -> click `Grant Permissions` -> click `Yes`.
31
+
32
+
## Step 3: Run the sample
33
+
34
+
1. Open `index.html` in [Visual Studio Code](https://code.visualstudio.com/download?wt.mc_id=adw-brandcore-editor-slink-downloads&gclid=EAIaIQobChMItJndsOXH1QIVFJR-Ch3uTgMREAAYASABEgLb2vD_BwE) or another text editor or IDE.
35
+
2. Inside `index.html` there is a section of `Input Vars` you can update to run the sample:
36
+
*`clientId` - (Required) update this with the `application id` you saved from `portal.azure.com`
37
+
*`replyUri` - (optional) update this if you are hosting `index.html` at an address other than `hottp://localhost:8080`
38
+
*`vstsApi` - (optional) update this if you would like to the sample to run a different VSTS API
39
+
*`vstsResourceId` - Do not change this value. It is used to receive VSTS ADAL authentication tokens
40
+
3. Navigate to the ADAL JS sample in cloned repo `vsts-auth-samples/AdalJsSample/` and start your http-server which will serve `index.hmtl` at `http://localhost:8080`.
41
+
4. Navigate to `http://localhost:8080`. Sign in with a user account from your AAD tenant which has access to at least 1 VSTS account. Displayed should be all VSTS known identity infromation about the signed in user account.
Copy file name to clipboardExpand all lines: ManagedClientConsoleAppSample/README.md
+25-7Lines changed: 25 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,25 +6,43 @@ The [Azure Active Directory Authentication Library (ADAL)](https://docs.microsof
6
6
7
7
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.
8
8
9
+
To run this sample you will need:
10
+
* Visual Studio 2017
11
+
* An Azure Active Directory (AAD) tenant. If you do not have one, follow these [steps to set up an AAD](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-howto-tenant)
12
+
* A user account in your AAD tenant
13
+
* A VSTS account backed by your AAD tenant where your user account has access. If you have an existing VSTS account not connected to your AAD tenant follow these [steps to connect you AAD tenant to your VSTS account](https://www.visualstudio.com/en-us/docs/setup-admin/team-services/manage-organization-access-for-your-account-vs)
14
+
9
15
## Step 1: Clone or download vsts-auth-samples repository
## Step 2: Register the sample application with you Azure Active Directory tenant
23
+
24
+
1. Sign in to the [Azure Portal](https://portal.azure.com).
25
+
2. On the top bar, click on your account and under the Directory list, choose the Active Directory tenant where you wish to register your application.
26
+
3. On the left hand navigation menu, select `Azure Active Directory`.
27
+
4. Click on `App registrations` and select `New application regirstation` from the top bar.
28
+
5. Enter a `name` for you application, ex. "Adal native app sample", choose `Native` for `application type`, and enter `http://localhost:8080` for the `Redirect URI`. Finally click `create` at the bottom of the screen.
29
+
6. Save the `Application ID` from your new application registration. You will need it later in this sample.
30
+
7. Grant Permissions for VSTS. Click `Required permissions` -> `add` -> `1 Select an API` -> type in and select `Microsoft Visual Studio Team Services` -> check the box for `Have full access to...` -> click `Save` -> click `Grant Permissions` -> click `Yes`.
31
+
32
+
## Step 3: Install and configure ADAL (optional)
17
33
18
34
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](https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory).
19
35
20
-
## Step 3: Run the sample
36
+
## Step 4: Run the sample
21
37
22
-
1. Navigate to the ADAL C# sample in cloned repo `vsts-auth-samples/ManagedClientConsoleAppSample/`
23
-
2. Use [Nuget package restore](https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore) to ensure you have all dependencies installed
24
-
3. Open the solution file `ManagedClientConsoleAppSample.csproj` in [Visual Studio 2017](https://www.visualstudio.com/downloads/)
38
+
1. Navigate to the ADAL C# sample in cloned repo `vsts-auth-samples/ManagedClientConsoleAppSample/`.
39
+
2. Use [Nuget package restore](https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore) to ensure you have all dependencies installed.
40
+
3. Open the solution file `ManagedClientConsoleAppSample.sln` in [Visual Studio 2017](https://www.visualstudio.com/downloads/).
25
41
4. Open CS file `Program.cs` and there is a section with input values to change at the top of the class:
26
-
*`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.
27
-
5. Build and run solution. After running you should see a list of all projects inside of myaccount.
42
+
*`vstsCollectionUrl` - update this with the url to your VSTS/TFS collection, e.g. http://myaccount.visualstudio.com for VSTS or http://myserver:8080/tfs/DefaultCollection for TFS.
43
+
*`clientId` - update this with the `application id` you saved from `portal.azure.com`
44
+
*`replyUri` - we have set this to `http://localhost:8080`, but please update it as necessary for your own app.
45
+
5. Build and run solution. After running you should see an interactive login prompt. Then after authentication and authorization, a list of all projects inside of your account.
0 commit comments