@@ -23,16 +23,16 @@ public static void Main(string[] args)
23
23
AuthenticationContext ctx = GetAuthenticationContext ( null ) ;
24
24
AuthenticationResult result = null ;
25
25
26
+ IPlatformParameters promptBehavior = new PlatformParameters ( ) ;
26
27
#if NET452
27
- IPlatformParameters p = new PlatformParameters ( PromptBehavior . Always ) ;
28
- #else
29
- IPlatformParameters p = new PlatformParameters ( ) ;
28
+ promptBehavior = new PlatformParameters ( PromptBehavior . Always ) ;
30
29
#endif
30
+
31
31
try
32
32
{
33
33
34
34
//PromptBehavior.RefreshSession will enforce an authn prompt every time. NOTE: Auto will take your windows login state if possible
35
- result = ctx . AcquireTokenAsync ( VSTSResourceId , clientId , new Uri ( replyUri ) , p ) . Result ;
35
+ result = ctx . AcquireTokenAsync ( VSTSResourceId , clientId , new Uri ( replyUri ) , promptBehavior ) . Result ;
36
36
Console . WriteLine ( "Token expires on: " + result . ExpiresOn ) ;
37
37
38
38
var bearerAuthHeader = new AuthenticationHeaderValue ( "Bearer" , result . AccessToken ) ;
@@ -41,7 +41,7 @@ public static void Main(string[] args)
41
41
catch ( UnauthorizedAccessException )
42
42
{
43
43
// If the token has expired, prompt the user with a login prompt
44
- result = ctx . AcquireTokenAsync ( VSTSResourceId , clientId , new Uri ( replyUri ) , p ) . Result ;
44
+ result = ctx . AcquireTokenAsync ( VSTSResourceId , clientId , new Uri ( replyUri ) , promptBehavior ) . Result ;
45
45
}
46
46
catch ( Exception ex )
47
47
{
0 commit comments