Skip to content

Commit 939e487

Browse files
committed
Added a readme and removed an empty comment.
1 parent 321e265 commit 939e487

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

NonInteractivePatGenerationSample/NonInteractivePatGenerationSample.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ VisualStudioVersion = 15.0.27004.2005
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NonInteractivePatGenerationSample", "NonInteractivePatGenerationSample\NonInteractivePatGenerationSample.csproj", "{2A8F9A96-2FB4-4FCA-A67C-44C757D354E3}"
77
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EF421301-2EA7-486F-A4FD-275164554E00}"
9+
ProjectSection(SolutionItems) = preProject
10+
README.md = README.md
11+
EndProjectSection
12+
EndProject
813
Global
914
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1015
Debug|Any CPU = Debug|Any CPU

NonInteractivePatGenerationSample/NonInteractivePatGenerationSample/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ public class Program
1717
private const string VstsResourceId = "499b84ac-1321-427f-aa17-267ca6975798";
1818

1919
// This is the resource for your own application registered in AAD (which needs access to the VSTS application).
20+
//
2021
private const string ClientId = "[your AAD application client ID]";
2122

2223
public static void Main(string[] args)
2324
{
2425
var adalCredential = new UserPasswordCredential(
25-
"[your AAD username]", //
26+
"[your AAD username]",
2627
"[your AAD password]"
2728
);
2829

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Non-interactive PAT generation Sample
2+
3+
This sample shows how to generate a Personal Access Token (PAT) using the [Client Libraries](https://www.visualstudio.com/en-us/docs/integrate/get-started/client-libraries/dotnet). You cannot use a PAT to generate a PAT and so this sample makes use of the Azure Active Directory Authentication Library (ADAL) to acquire an AAD token which is then used as a credential to authenticate requests to VSTS. This sample also uses the UserPasswordCredential rather than relying on the interactive pop-up dialog - this can be useful in scenarios where you need to generate a PAT associated with an account that does not have interactive login rights.
4+
5+
## Sample Application
6+
7+
This sample shows the basic flow for calling ADAL, and then using the resulting token as credentials to call the ```CreateSessionToken``` method on the ```DelegatedAuthorizationHttpClient``` class. In order to run this application you will need to [register your own AAD application](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications).
8+
9+
## Step 1: Clone or download vsts-auth-samples repository
10+
11+
From a shell or command line:
12+
```no-highlight
13+
git clone https://github.com/Microsoft/vsts-auth-samples.git
14+
```
15+
16+
## Step 2: Run the sample
17+
18+
1. Navigate to the sample in cloned repo `vsts-auth-samples/NonInteractivePatGenerationSample/`
19+
2. Use [Nuget package restore](https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore) to ensure you have all dependencies installed
20+
3. Open the solution file `NonInteractivePatGenerationSample.sln` in [Visual Studio 2017](https://www.visualstudio.com/downloads/)
21+
4. Open CS file `Program.cs` and look for the ```[value]``` placeholders.
22+
5. Replace them with the appropriate values.
23+
6. Build and run the solution, the generate PAT will be output to the console window.

0 commit comments

Comments
 (0)