Skip to content

Commit c2358f8

Browse files
committed
Updates for Peaky's suggestions.
1 parent 102c09d commit c2358f8

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

NonInteractivePatGenerationSample/NonInteractivePatGenerationSample/Program.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,16 @@ public class Program
1616
// This is the resource ID for the VSTS application - don't change this.
1717
private const string VstsResourceId = "499b84ac-1321-427f-aa17-267ca6975798";
1818

19-
// This is the resource for your own application registered in AAD (which needs access to the VSTS application).
20-
//
21-
private const string ClientId = "[your AAD application client ID]";
22-
2319
public static void Main(string[] args)
2420
{
25-
var adalCredential = new UserPasswordCredential(
26-
"[your AAD username]",
27-
"[your AAD password]"
28-
);
21+
var username = "[your AAD username]"; // This is your AAD username in the form [email protected].
22+
var password = "[your AAD password]"; // This is your AAD password.
23+
var aadApplicationID = "[your AAD application ID]"; // Created when you register an AAD application: https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications.
24+
25+
var adalCredential = new UserPasswordCredential(username, password);
2926

3027
var authenticationContext = new AuthenticationContext("https://login.microsoftonline.com/common");
31-
var result = authenticationContext.AcquireTokenAsync(VstsResourceId, ClientId, adalCredential).Result;
28+
var result = authenticationContext.AcquireTokenAsync(VstsResourceId, aadApplicationID, adalCredential).Result;
3229

3330
var token = new VssAadToken(result);
3431
var vstsCredential = new VssAadCredential(token);

NonInteractivePatGenerationSample/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ git clone https://github.com/Microsoft/vsts-auth-samples.git
1818
1. Navigate to the sample in cloned repo `vsts-auth-samples/NonInteractivePatGenerationSample/`
1919
2. Use [Nuget package restore](https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore) to ensure you have all dependencies installed
2020
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.
21+
4. Open CS file ```Program.cs``` and look at the first few lines in the ```Main``` method. Replace the username and password with the appropriate values. You will need to get the ```aadApplicationID``` value by [registering your app in AAD](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications).
2322
6. Build and run the solution, the generate PAT will be output to the console window.

0 commit comments

Comments
 (0)