Skip to content

Commit 1ec2ce8

Browse files
committed
addressing Justin's comments
1 parent c0dcdbb commit 1ec2ce8

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

ClientLibraryConsoleAppSample/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Client Libraries Sample
22

3-
The [Client Libraries](https://www.visualstudio.com/en-us/docs/integrate/get-started/client-libraries/dotnet) are .NET libraries made to simplify integration with Visual Studio Team Services and Team Foundation Server (2015 and later). They allow access to both the Traditional Client Object Model and [new REST APIs](https://www.visualstudio.com/en-us/docs/integrate/api/overview).
3+
For native applications the best way to authenticate and access VSTS resources is using the [Client Libraries](https://www.visualstudio.com/en-us/docs/integrate/get-started/client-libraries/dotnet). They are .NET libraries made to simplify integration with Visual Studio Team Services and Team Foundation Server (2015 and later). They allow access to both the Traditional Client Object Model and [new REST APIs](https://www.visualstudio.com/en-us/docs/integrate/api/overview).
44

55
## Sample Application
66

JavascriptWebAppSample/README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Javascirpt Web App Sample
1+
# Javascript Web App Sample
22

3-
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.
3+
For javascript web applications that want access to resources like VSTS REST API's, they will have to support an authentication flow for their users. The [Azure Active Directory Authentication Library (ADAL) for JS](https://github.com/AzureAD/azure-activedirectory-library-for-js) enables javascript application developers to setup inerative authentication flows and obtain access tokens for API usage.
44

55
## Sample Application
66

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 display all project contained in a VSTS account/TFS collection.
7+
This buildable sample will walk you through the steps to create a single page javascript application which uses ADAL to authenticate a user via an interactive prompt and display all projects contained in a VSTS account/TFS collection.
88

99
To run this sample you will need:
1010
* Http-server. You can download [NPM http server](https://www.npmjs.com/package/http-server) if you need one.
@@ -24,20 +24,21 @@ git clone https://github.com/Microsoft/vsts-auth-samples.git
2424
1. Sign in to the [Azure Portal](https://portal.azure.com).
2525
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.
2626
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.
27+
4. Click on `App registrations` and select `New application registration` from the top bar.
2828
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.
2929
6. Save the `Application ID` from your new application registration. You will need it later in this sample.
3030
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`.
3131

3232
## Step 3: Run the sample
3333

3434
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` - (Required) update this with your VSTS/TFS collection, e.g. http://myaccount.visualstudio.com/DefaultCollection/_apis/projects?api-version=2.0 for VSTS or http://myserver:8080/tfs/DefaultCollection/_apis/projects?api-version=2.0 for TFS. If you would like to the sample to run a different VSTS API please change the entire string
35+
2. Inside `index.html` there is a section called `Input Vars` you will need to update to run the sample:
36+
* `clientId` - (Required) update this with the `application id` you saved from step 2.6 above
37+
* `replyUri` - (optional) In single page apps this should be the app URL itself. We have set this to `http://localhost:8080`(where we will host our app), but if you are hosting your app at another URL please change this value and the reply URI in `portal.azure.com`
38+
* `logoutredirectUri` - (optional) update if you are hosting your app at a location other than `http://localhost:8080`
39+
* `vstsApi` - (Required) update this with your VSTS/TFS collection, e.g. http://myaccount.visualstudio.com/DefaultCollection/_apis/projects?api-version=2.0 for VSTS or http://myserver:8080/tfs/DefaultCollection/_apis/projects?api-version=2.0 for TFS. If you would like to the sample to run a different VSTS API please change the entire string. [Learn more about other VSTS REST API's](https://www.visualstudio.com/en-us/docs/integrate/get-started/rest/basics)
3940
* `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+
3. Navigate to the ADAL JS sample in cloned repo `vsts-auth-samples/JavascriptWebAppSample/` and start your http-server which will by default serve `index.hmtl` at `http://localhost:8080`.
4142
4. Navigate to `http://localhost:8080`. Sign in with a user account from your AAD tenant which has access to the VSTS account specified in the `vstsApi`. All projects contained in the account should be displayed.
4243

4344

JavascriptWebAppSample/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@
2020
<script type="text/javascript">
2121
//========= Input Vars ================================
2222
var clientId = '57c5c51c-2036-433a-befa-ebefc7f10689'; //Update with your app regirstion's Application ID
23-
var replyUri = 'http://localhost:8080'; //Update if hosting webpage non-locally
24-
var vstsApi = 'https://myaccount.visualstudio.com/DefaultCollection/_apis/projects?api-version=2.0';//'https://app.vssps.visualstudio.com/_apis/profile/profiles/me?api-version=1.0';//Update if want to access a different vsts API
23+
var replyUri = 'http://localhost:8080'; //Where you will receive the token.
24+
var logoutRedirectUri = 'http://localhost:8080'; //Update if you are hosting your webpage somewhere else
25+
var vstsApi = 'https://myaccount.visualstudio.com/_apis/projects?api-version=2.0';//'https://app.vssps.visualstudio.com/_apis/profile/profiles/me?api-version=1.0';//Update if want to access a different vsts API
2526
var vstsResourceId = '499b84ac-1321-427f-aa17-267ca6975798'; //Do not change
2627
//=====================================================
2728

2829
// Set up ADAL
2930
var authContext = new AuthenticationContext({
3031
clientId: clientId,
31-
postLogoutRedirectUri: replyUri //Where you return upon signout
32+
redirectUri:replyUri,
33+
postLogoutRedirectUri: logoutRedirectUri //Where you return upon signout
3234
});
3335
// Make an AJAX request to the VSTS REST API and print the response as JSON.
3436
var getCurrentUserInfo = function (access_token) {

ManagedClientConsoleAppSample/Program.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Linq;
44
using System.Net.Http;
55
using System.Net.Http.Headers;
6-
using System.Threading;
76

87
namespace ManagedClientConsoleAppSample
98
{
@@ -13,7 +12,7 @@ class Program
1312
internal const string vstsCollectionUrl = "https://myaccount.visualstudio.com"; //change to the URL of your VSTS account; NOTE: This must use HTTPS
1413
// internal const string vstsCollectioUrl = "http://myserver:8080/tfs/DefaultCollection" alternate URL for a TFS collection
1514
internal const string clientId = "0fa17cf4-f75c-4185-ab9a-7c5ea47ca073"; //change to your app registration's Application ID
16-
internal const string replyUri = "http://localhost:8080"; //change to your app registration's reply URI.
15+
internal const string replyUri = "http://adaljssample"; //change to your app registration's reply URI.
1716
//==========================================================================
1817

1918
internal const string VSTSResourceId = "499b84ac-1321-427f-aa17-267ca6975798"; //Constant value to target VSTS. Do not change
@@ -80,7 +79,6 @@ private static void ListProjects(AuthenticationHeaderValue authHeader)
8079
{
8180
Console.WriteLine("\tSuccesful REST call");
8281
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
83-
Thread.Sleep(10000);
8482
}
8583
else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
8684
{

ManagedClientConsoleAppSample/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# Managed Client ADAL Sample
22

3-
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.
3+
For native applications which can support interative authentication prompts, the [Azure Active Directory Authentication Library (ADAL)](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-authentication-libraries) makes it easy to setup authentication flows for users.
4+
5+
For native applications which cannot support interactive authentication prompts, please check out our [Device Profile Sample](./../DeviceProfileSample/README.md).
46

57
## Sample Application
68

79
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/TFS collection.
810

911
To run this sample you will need:
10-
* Visual Studio 2017
12+
* [Visual Studio IDE](https://www.visualstudio.com/vs/)
1113
* 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)
1214
* A user account in your AAD tenant
1315
* 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)
@@ -25,7 +27,7 @@ git clone https://github.com/Microsoft/vsts-auth-samples.git
2527
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.
2628
3. On the left hand navigation menu, select `Azure Active Directory`.
2729
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.
30+
5. Enter a `name` for you application, ex. "Adal native app sample", choose `Native` for `application type`, and enter `http://adaljssample` for the `Redirect URI`. Finally click `create` at the bottom of the screen.
2931
6. Save the `Application ID` from your new application registration. You will need it later in this sample.
3032
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`.
3133

@@ -41,9 +43,6 @@ Package: `Microsoft.Identity.Model.Clients.ActiveDirectory` has already been ins
4143
4. Open CS file `Program.cs` and there is a section with input values to change at the top of the class:
4244
* `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.
4345
* `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.
46+
* `replyUri` - we have set this to `http://adaljssample`, but please update it as necessary for your own app.
4547
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.
4648

47-
48-
49-

0 commit comments

Comments
 (0)