Skip to content

Commit 4eb3827

Browse files
committed
updated readmes and code addressing comments
1 parent 69f3a51 commit 4eb3827

File tree

21 files changed

+289
-239
lines changed

21 files changed

+289
-239
lines changed

DeviceProfileSample/DeviceProfileSample.csproj

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@
3333
<WarningLevel>4</WarningLevel>
3434
</PropertyGroup>
3535
<ItemGroup>
36-
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.14.1.10, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
37-
<HintPath>packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.14.1\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
38-
<Private>True</Private>
36+
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.16.0.14, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
37+
<HintPath>packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.16.0\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
3938
</Reference>
40-
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.14.1.10, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
41-
<HintPath>packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.14.1\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll</HintPath>
42-
<Private>True</Private>
39+
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.16.0.14, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
40+
<HintPath>packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.16.0\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll</HintPath>
4341
</Reference>
4442
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
4543
<HintPath>packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>

DeviceProfileSample/Program.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
using Microsoft.IdentityModel.Clients.ActiveDirectory;
2-
using Newtonsoft.Json.Linq;
32
using System;
4-
using System.Collections.Generic;
5-
using System.Globalization;
63
using System.Linq;
74
using System.Net.Http;
85
using System.Net.Http.Headers;
9-
using System.Text;
10-
using System.Threading.Tasks;
116

127
namespace DeviceProfileSample
138
{
149
public class Program
1510
{
1611
//============= Config [Edit these with your settings] =====================
1712
internal const string vstsCollectionUrl = "https://myaccount.visualstudio.com"; //change to the URL of your VSTS account; NOTE: This must use HTTPS
13+
internal const string clientId = "872cd9fa-d31f-45e0-9eab-6e460a02d1f1"; //update this with your Application ID from step 2.6 (do not change this if you have an MSA backed account)
1814
//==========================================================================
1915

2016
internal const string VSTSResourceId = "499b84ac-1321-427f-aa17-267ca6975798"; //Static value to target VSTS. Do not change
21-
internal const string clientId = "872cd9fa-d31f-45e0-9eab-6e460a02d1f1"; //VS ClientId. Please use this instead of your app's clientId
17+
2218

2319
public static void Main(string[] args)
2420
{

DeviceProfileSample/README.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,56 @@ For a headless text output client application, it is not possible authenticate t
66

77
This buildable sample will walk you through the steps to create a client-side console application which uses ADAL to authenticate a user via the [Device Profile flow](https://azure.microsoft.com/en-us/resources/samples/active-directory-dotnet-deviceprofile/?v=17.23h) and returns a JSON string containing all account team project data viewable by the authenticated user.
88

9+
To run this sample for an [Azure Active Directory](https://docs.microsoft.com/en-us/azure/active-directory/active-directory-whatis) backed VSTS account you will need:
10+
* [Visual Studio IDE](https://www.visualstudio.com/vs/)
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 your 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+
To run this sample for a [Microsoft Account](https://account.microsoft.com/account) backed VSTS account you will need:
16+
* [Visual Studio IDE](https://www.visualstudio.com/vs/)
17+
* A VSTS account not connected to AAD
18+
919
## Step 1: Clone or download vsts-auth-samples repository
1020

1121
From a shell or command line:
1222
```no-highlight
1323
git clone https://github.com/Microsoft/vsts-auth-samples.git
1424
```
1525

16-
## Step 2: Install and configure ADAL (optional)
26+
## Step 2: Register the sample application with you Azure Active Directory tenant (AAD backed VSTS account)
27+
28+
```no-highlight
29+
If you are a Microsoft Account backed VSTS account please skip this step.
30+
```
31+
32+
1. Sign in to the [Azure Portal](https://portal.azure.com).
33+
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.
34+
3. On the left hand navigation menu, select `Azure Active Directory`.
35+
4. Click on `App registrations` and select `New application registration` from the top bar.
36+
5. Enter a `name` for you application, ex. "Adal native app sample", choose `Native` for `application type`, and enter `http://adalsample` for the `Redirect URI`. Finally click `create` at the bottom of the screen.
37+
6. Save the `Application ID` from your new application registration. You will need it later in this sample.
38+
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 `Delegated Permissions` -> click `Select` -> click `Done` -> click `Grant Permissions` -> click `Yes`.
39+
40+
## Step 3: Install and configure ADAL (optional)
1741

1842
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).
1943

20-
## Step 3: Run the sample
44+
## Step 4a: Run the sample (AAD backed VSTS account)
45+
46+
1. Navigate to the sample in cloned repo `vsts-auth-samples/DeviceProfileSample/`
47+
2. Open the solution file `DeviceProfileSample.sln` in [Visual Studio 2017](https://www.visualstudio.com/downloads/)
48+
3. Use [Nuget package restore](https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore) to ensure you have all dependencies installed
49+
4. Open CS file `Program.cs` and there is a section with input values to change at the top of the class:
50+
* `vstsCollectionUrl` - Update this value to your VSTS collection URL, e.g. http://myaccount.visualstudio.com.
51+
* `clientId` - Update this value with the `Application ID` you saved in step 2.6.
52+
5. Build and run solution. You should see a console window with instructions on how to authenticate via the Device Profile flow. After authenticating you should see all team project information viewable by the authenticated identity displayed in the console window.
53+
54+
## Step 4b: Run the sample (Microsoft Account backed VSTS account)
2155

2256
1. Navigate to the sample in cloned repo `vsts-auth-samples/DeviceProfileSample/`
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 `DeviceProfileSample.csproj` in [Visual Studio 2017](https://www.visualstudio.com/downloads/)
57+
2. Open the solution file `DeviceProfileSample.sln` in [Visual Studio 2017](https://www.visualstudio.com/downloads/)
58+
3. Use [Nuget package restore](https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore) to ensure you have all dependencies installed
2559
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 collection, e.g. http://myaccount.visualstudio.com for VSTS.
27-
5. Build and run solution. You should see a console window with instruction on how to authenticate via the Device Profile flow. After authenticating you should see all team project information viewable by the authenticated identity displayed in the console window.
60+
* `vstsCollectionUrl` - Update this value to your VSTS collection URL, e.g. http://myaccount.visualstudio.com.
61+
5. Build and run solution. You should see a console window with instructions on how to authenticate via the Device Profile flow. After authenticating you should see all team project information viewable by the authenticated identity displayed in the console window.

DeviceProfileSample/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.14.1" targetFramework="net452" />
3+
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.16.0" targetFramework="net452" />
44
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
55
</packages>
File renamed without changes.

VstsTfsSample/VstsTfsSample.csproj renamed to DualSupportSample/DualSupportClientSample.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<ProjectGuid>{755BC9EF-A095-48DC-BBF6-AF39F8C3363E}</ProjectGuid>
88
<OutputType>Exe</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>ManagedClientConsoleAppSample</RootNamespace>
11-
<AssemblyName>ManagedClientConsoleAppSample</AssemblyName>
10+
<RootNamespace>DualSupportClientSample</RootNamespace>
11+
<AssemblyName>DualSupportClientSample</AssemblyName>
1212
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -33,7 +33,7 @@
3333
<WarningLevel>4</WarningLevel>
3434
</PropertyGroup>
3535
<PropertyGroup>
36-
<StartupObject>ManagedClientConsoleAppSample.Program</StartupObject>
36+
<StartupObject>DualSupportClientSample.Program</StartupObject>
3737
</PropertyGroup>
3838
<ItemGroup>
3939
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.13.8.999, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">

VstsTfsSample/VstsTfsSample.sln renamed to DualSupportSample/DualSupportClientSample.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
44
VisualStudioVersion = 15.0.26228.9
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VstsTfsSample", "VstsTfsSample.csproj", "{755BC9EF-A095-48DC-BBF6-AF39F8C3363E}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DualSupportClientSample", "DualSupportClientSample.csproj", "{755BC9EF-A095-48DC-BBF6-AF39F8C3363E}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution

DualSupportSample/Program.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using Microsoft.VisualStudio.Services.Client;
3+
using Microsoft.VisualStudio.Services.WebApi;
4+
using Microsoft.TeamFoundation.Core.WebApi;
5+
using System.Collections.Generic;
6+
7+
namespace DualSupportClientSample
8+
{
9+
//After running the console will close so please add a breakpoint or sleep to see output.
10+
class Program
11+
{
12+
//============= Config [Edit these with your settings] =====================
13+
internal const string vstsOrTfsCollectionUrl = "VSTS: https://*.visualstudio.com or TFS: https://*:8080/tfs/defaultcollection"; //change to the URL of your VSTS or TFS account
14+
//==========================================================================
15+
16+
public static void Main(string[] args)
17+
{
18+
try
19+
{
20+
//Based on collection URL will either start an interactive login session or use local Windows credential authentication
21+
VssConnection connection = new VssConnection(new Uri(vstsOrTfsCollectionUrl), new VssClientCredentials());
22+
23+
ProjectHttpClient projectClient = connection.GetClient<ProjectHttpClient>();
24+
IEnumerable<TeamProjectReference> projects = projectClient.GetProjects().Result;
25+
foreach (TeamProjectReference p in projects)
26+
{
27+
Console.WriteLine(p.Name);
28+
}
29+
}
30+
catch (Exception ex)
31+
{
32+
Console.WriteLine("{0}: {1}", ex.GetType(), ex.Message);
33+
}
34+
}
35+
}
36+
}

DualSupportSample/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Dual Support (VSTS/TFS) Client Sample
2+
3+
For windows native applications which want to target both VSTS and TFS we recommend using the [Client Libraries for VSTS and TFS](https://www.visualstudio.com/en-us/docs/integrate/get-started/client-libraries/dotnet) to generate interactive sign in prompts for VSTS users and leverage seemless Windows credential authentication for TFS users.
4+
5+
## Sample Application
6+
7+
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 VSTS or TFS user and return a list of all projects inside a selected VSTS account or TFS collection.
8+
9+
To run this sample you will need:
10+
* [Visual Studio IDE](https://www.visualstudio.com/vs/)
11+
* A [VSTS account](https://www.visualstudio.com/team-services/)
12+
13+
## Step 1: Clone or download vsts-auth-samples repository
14+
15+
From a shell or command line:
16+
```no-highlight
17+
git clone https://github.com/Microsoft/vsts-auth-samples.git
18+
```
19+
20+
## Step 2: Install and configure Client libraries (optional)
21+
22+
Packages: [Microsoft.VisualStudio.Services.Client](https://www.nuget.org/packages/Microsoft.VisualStudio.Services.Client), and [Microsoft.TeamFoundation.Core.WebApi](https://www.nuget.org/packages/Microsoft.TeamFoundationServer.Client) 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.
23+
24+
## Step 3: Run the sample
25+
26+
1. Navigate to the ADAL C# sample in cloned repo `vsts-auth-samples/DualSupportClientSample/`.
27+
2. Open the solution file `VstsTfsSample.sln` in [Visual Studio 2017](https://www.visualstudio.com/downloads/).
28+
3. Use [Nuget package restore](https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore) to ensure you have all dependencies installed.
29+
4. Open CS file `Program.cs` and there is a section with input values to change at the top of the class:
30+
* `vstsOrTfsCollectionUrl` - 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.
31+
5. Build and run the solution. After running you should see an interactive login prompt if you are a VSTS 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.
32+

0 commit comments

Comments
 (0)