Skip to content

Commit c69d43d

Browse files
author
Justin Marks (MSFT)
committed
Updates to MangedClient sample
1 parent 919c170 commit c69d43d

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

ManagedClientConsoleAppSample/Program.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using Microsoft.IdentityModel.Clients.ActiveDirectory;
2+
using System;
33
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using Microsoft.IdentityModel.Clients.ActiveDirectory;
7-
using System.Net.Http.Headers;
84
using System.Net.Http;
9-
using System.Threading;
10-
using Newtonsoft.Json;
11-
using System.IO;
5+
using System.Net.Http.Headers;
126

137
namespace ManagedClientConsoleAppSample
148
{
159
class Program
16-
{
10+
{
1711
//============= Config [Edit these with your settings] =====================
18-
internal const string vstsCollectionUrl = "http://myaccount.visualstudio.com"; //change to the URL of your VSTS account
12+
internal const string vstsCollectionUrl = "https://myaccount.visualstudio.com"; //change to the URL of your VSTS account; NOTE: This must use HTTPS
1913
// internal const string vstsCollectioUrl = "http://myserver:8080/tfs/DefaultCollection" alternate URL for a TFS collection
2014
//==========================================================================
2115

@@ -29,7 +23,7 @@ public static void Main(string[] args)
2923
try
3024
{
3125
//PromptBehavior.RefreshSession will enforce an authn prompt every time. NOTE: Auto will take your windows login state if possible
32-
result = ctx.AcquireTokenAsync(VSTSResourceId, clientId, new Uri("urn:ietf:wg:oauth:2.0:oob"), new PlatformParameters(PromptBehavior.Auto)).Result;
26+
result = ctx.AcquireTokenAsync(VSTSResourceId, clientId, new Uri("urn:ietf:wg:oauth:2.0:oob"), new PlatformParameters(PromptBehavior.Always)).Result;
3327
Console.WriteLine("Token expires on: " + result.ExpiresOn);
3428

3529
var bearerAuthHeader = new AuthenticationHeaderValue("Bearer", result.AccessToken);

0 commit comments

Comments
 (0)