@@ -23,16 +23,16 @@ public static void Main(string[] args)
2323 AuthenticationContext ctx = GetAuthenticationContext ( null ) ;
2424 AuthenticationResult result = null ;
2525
26+ IPlatformParameters promptBehavior = new PlatformParameters ( ) ;
2627#if NET452
27- IPlatformParameters p = new PlatformParameters ( PromptBehavior . Always ) ;
28- #else
29- IPlatformParameters p = new PlatformParameters ( ) ;
28+ promptBehavior = new PlatformParameters ( PromptBehavior . Always ) ;
3029#endif
30+
3131 try
3232 {
3333
3434 //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 ;
3636 Console . WriteLine ( "Token expires on: " + result . ExpiresOn ) ;
3737
3838 var bearerAuthHeader = new AuthenticationHeaderValue ( "Bearer" , result . AccessToken ) ;
@@ -41,7 +41,7 @@ public static void Main(string[] args)
4141 catch ( UnauthorizedAccessException )
4242 {
4343 // 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 ;
4545 }
4646 catch ( Exception ex )
4747 {
0 commit comments