public static string AcquireAccessCode(AuthenticationContext context, string resource, string clientId, Uri redirectUri, UserIdentifier userId)
 {
     var handler = new AcquireTokenInteractiveHandler(context.Authenticator, context.TokenCache, resource, clientId, redirectUri, PromptBehavior.Auto, userId, null,
         context.CreateWebAuthenticationDialog(PromptBehavior.Auto), true);
     handler.CallState = null;
     context.Authenticator.AuthorizationUri = context.Authority + "oauth2/authorize";
     handler.AcquireAuthorization();
     return handler.authorizationResult.Code;
 }
 public async static Task<string> AcquireAccessCodeAsync(AuthenticationContext context, string resource, string clientId, Uri redirectUri, UserIdentifier userId)
 {
     var handler = new AcquireTokenInteractiveHandler(context.Authenticator, context.TokenCache, resource, clientId, redirectUri, new PlatformParameters(PromptBehavior.Auto, null), userId, null,
         context.CreateWebAuthenticationDialog(new PlatformParameters(PromptBehavior.Auto, null)));
     handler.CallState = null;
     context.Authenticator.AuthorizationUri = context.Authority + "oauth2/authorize";
     await handler.AcquireAuthorizationAsync();
     return handler.authorizationResult.Code;
 }