private void AcquireTokenAndContinueCommon(string resource, string clientId, Uri redirectUri, UserIdentifier userId, string extraQueryParameters, AuthenticationContextDelegate authDelegate) { IWebUI webUi = this.CreateWebAuthenticationDialog(); var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, resource, clientId, redirectUri, webUi.PromptBehavior, userId, extraQueryParameters, webUi, false); handler.AcquireAuthorization(); this.authenticationContextDelegate = authDelegate; }
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; }
/// <summary> /// Continues security token acquisition from the authority. /// </summary> /// <param name="args">Information to an app that was launched after being suspended for a web authentication broker operation.</param> /// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns> public IAsyncOperation <AuthenticationResult> ContinueAcquireTokenAsync(IWebAuthenticationBrokerContinuationEventArgs args) { var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, this.authenticationContextDelegate, args); try { return(RunTaskAsAsyncOperation(handler.RunAsync())); } finally { this.authenticationContextDelegate = null; } }
private async Task <AuthenticationResult> AcquireTokenCommonAsync(string resource, string clientId, Uri redirectUri, IPlatformParameters parameters, UserIdentifier userId, string extraQueryParameters = null) { RequestData requestData = new RequestData { Authenticator = this.Authenticator, TokenCache = this.TokenCache, Resource = resource, ClientKey = new ClientKey(clientId), ExtendedLifeTimeEnabled = this.ExtendedLifeTimeEnabled, }; var handler = new AcquireTokenInteractiveHandler(requestData, redirectUri, parameters, userId, extraQueryParameters, this.CreateWebAuthenticationDialog(parameters)); return(await handler.RunAsync().ConfigureAwait(false)); }
/// <summary> /// Gets URL of the authorize endpoint including the query parameters. /// </summary> /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param> /// <param name="clientId">Identifier of the client requesting the token.</param> /// <param name="redirectUri">Address to return to upon receiving a response from the authority.</param> /// <param name="userId">Identifier of the user token is requested for. This parameter can be <see cref="UserIdentifier"/>.Any.</param> /// <param name="extraQueryParameters">This parameter will be appended as is to the query string in the HTTP authentication request to the authority. The parameter can be null.</param> /// <returns>URL of the authorize endpoint including the query parameters.</returns> public async Task <Uri> GetAuthorizationRequestUrlAsync(string resource, string clientId, Uri redirectUri, UserIdentifier userId, string extraQueryParameters) { RequestData requestData = new RequestData { Authenticator = this.Authenticator, TokenCache = this.TokenCache, Resource = resource, ClientKey = new ClientKey(clientId), ExtendedLifeTimeEnabled = ExtendedLifeTimeEnabled }; var handler = new AcquireTokenInteractiveHandler(requestData, redirectUri, null, userId, extraQueryParameters, null); return(await handler.CreateAuthorizationUriAsync(this.CorrelationId).ConfigureAwait(false)); }
private async Task <AuthenticationResult> RunInteractiveHandlerAsync(AcquireTokenInteractiveHandler handler) { AuthenticationResult result = await RunTask(handler.RunAsync()); // Execute callback if (this.authenticationContextDelegate != null) { var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => this.authenticationContextDelegate(result)); this.authenticationContextDelegate = null; } return(result); }
private async Task <AuthenticationResult> AcquireTokenWithClaimsCommonAsync(string resource, ClientKey clientKey, Uri redirectUri, IPlatformParameters parameters, UserIdentifier userId, string extraQueryParameters, IWebUI webUI, string claims) { RequestData requestData = new RequestData { Authenticator = this.Authenticator, TokenCache = this.TokenCache, Resource = resource, ClientKey = clientKey, ExtendedLifeTimeEnabled = this.ExtendedLifeTimeEnabled }; var handler = new AcquireTokenInteractiveHandler(requestData, redirectUri, parameters, userId, extraQueryParameters, webUI, claims); return(await handler.RunAsync().ConfigureAwait(false)); }
private async Task<AuthenticationResult> AcquireTokenCommonAsync(string resource, string clientId, Uri redirectUri, PromptBehavior promptBehavior, UserIdentifier userId, string extraQueryParameters = null, bool callSync = false) { var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, resource, clientId, redirectUri, promptBehavior, userId, extraQueryParameters, this.CreateWebAuthenticationDialog(promptBehavior), callSync); return await handler.RunAsync(); }
private void AcquireTokenAndContinueCommon(string resource, string clientId, Uri redirectUri, UserIdentifier userId, string extraQueryParameters, AuthenticationContextDelegate authDelegate) { IWebUI webUi = this.CreateWebAuthenticationDialog(); var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, resource, clientId, redirectUri, webUi.PromptBehavior, userId, extraQueryParameters, webUi, false); handler.AcquireAuthorization(); this.authenticationContextDelegate = authDelegate; }
private async Task<AuthenticationResult> RunInteractiveHandlerAsync(AcquireTokenInteractiveHandler handler) { AuthenticationResult result = await RunTask(handler.RunAsync()); // Execute callback if (this.authenticationContextDelegate != null) { var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => this.authenticationContextDelegate(result)); this.authenticationContextDelegate = null; } return result; }
private async Task<AuthenticationResult> AcquireTokenCommonAsync(string resource, string clientId, Uri redirectUri, IPlatformParameters parameters, UserIdentifier userId, string extraQueryParameters = null) { var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, resource, clientId, redirectUri, parameters, userId, extraQueryParameters, this.CreateWebAuthenticationDialog(parameters)); return await handler.RunAsync(); }
/// <summary> /// Gets URL of the authorize endpoint including the query parameters. /// </summary> /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param> /// <param name="clientId">Identifier of the client requesting the token.</param> /// <param name="redirectUri">Address to return to upon receiving a response from the authority.</param> /// <param name="userId">Identifier of the user token is requested for. This parameter can be <see cref="UserIdentifier"/>.Any.</param> /// <param name="extraQueryParameters">This parameter will be appended as is to the query string in the HTTP authentication request to the authority. The parameter can be null.</param> /// <returns>URL of the authorize endpoint including the query parameters.</returns> public async Task<Uri> GetAuthorizationRequestUrlAsync(string resource, string clientId, Uri redirectUri, UserIdentifier userId, string extraQueryParameters) { var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, resource, clientId, redirectUri, null, userId, extraQueryParameters, null); return await handler.CreateAuthorizationUriAsync(this.CorrelationId); }
/// <summary> /// Gets URL of the authorize endpoint including the query parameters. /// </summary> /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param> /// <param name="clientId">Identifier of the client requesting the token.</param> /// <param name="redirectUri">Address to return to upon receiving a response from the authority.</param> /// <param name="userId">Identifier of the user token is requested for. This parameter can be <see cref="UserIdentifier"/>.Any.</param> /// <param name="extraQueryParameters">This parameter will be appended as is to the query string in the HTTP authentication request to the authority. The parameter can be null.</param> /// <returns>URL of the authorize endpoint including the query parameters.</returns> public async Task <Uri> GetAuthorizationRequestUrlAsync(string resource, string clientId, Uri redirectUri, UserIdentifier userId, string extraQueryParameters) { var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, resource, clientId, redirectUri, null, userId, extraQueryParameters, null, true); return(await handler.CreateAuthorizationUriAsync(this.CorrelationId)); }
/// <summary> /// Continues security token acquisition from the authority. /// </summary> /// <param name="args">Information to an app that was launched after being suspended for a web authentication broker operation.</param> /// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns> public IAsyncOperation<AuthenticationResult> ContinueAcquireTokenAsync(IWebAuthenticationBrokerContinuationEventArgs args) { var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, args); return this.RunInteractiveHandlerAsync(handler).AsAsyncOperation(); }
private async Task <AuthenticationResult> AcquireTokenCommonAsync(string resource, string clientId, Uri redirectUri, IAuthorizationParameters parameters, UserIdentifier userId, string extraQueryParameters = null, bool callSync = false) { var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, resource, clientId, redirectUri, parameters, userId, extraQueryParameters, this.CreateWebAuthenticationDialog(parameters), callSync); return(await handler.RunAsync()); }
/// <summary> /// Continues security token acquisition from the authority. /// </summary> /// <param name="args">Information to an app that was launched after being suspended for a web authentication broker operation.</param> /// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns> public IAsyncOperation <AuthenticationResult> ContinueAcquireTokenAsync(IWebAuthenticationBrokerContinuationEventArgs args) { var handler = new AcquireTokenInteractiveHandler(this.Authenticator, this.TokenCache, args); return(this.RunInteractiveHandlerAsync(handler).AsAsyncOperation()); }