/// <summary> /// Acquires security token from the authority using an authorization code previously received. /// This method does not lookup token cache, but stores the result in it, so it can be looked up using other methods such as <see cref="AuthenticationContext.AcquireTokenSilentAsync(string, string, UserIdentifier)"/>. /// </summary> /// <param name="ctx">Authentication context instance</param> /// <param name="authorizationCode">The authorization code received from service authorization endpoint.</param> /// <param name="redirectUri">The redirect address used for obtaining authorization code.</param> /// <param name="clientCertificate">The client certificate to use for token acquisition.</param> /// <param name="resource">Identifier of the target resource that is the recipient of the requested token. It can be null if provided earlier to acquire authorizationCode.</param> /// <returns>It contains Access Token, its expiration time, user information.</returns> public static async Task <AuthenticationResult> AcquireTokenByAuthorizationCodeAsync( this AuthenticationContext ctx, string authorizationCode, Uri redirectUri, IClientAssertionCertificate clientCertificate, string resource) { return(await ctx.AcquireTokenByAuthorizationCodeCommonAsync(authorizationCode, redirectUri, new ClientKey(clientCertificate, ctx.Authenticator), resource).ConfigureAwait(false)); }
/// <summary> /// Acquires security token from the authority using an authorization code previously received. /// This method does not lookup token cache, but stores the result in it, so it can be looked up using other methods such as <see cref="AuthenticationContext.AcquireTokenSilentAsync(string, string, UserIdentifier)"/>. /// </summary> /// <param name="ctx">Authentication context instance</param> /// <param name="authorizationCode">The authorization code received from service authorization endpoint.</param> /// <param name="redirectUri">The redirect address used for obtaining authorization code.</param> /// <param name="clientAssertion">The client assertion to use for token acquisition.</param> /// <returns>It contains Access Token, its expiration time, user information.</returns> public static async Task <AuthenticationResult> AcquireTokenByAuthorizationCodeAsync( this AuthenticationContext ctx, string authorizationCode, Uri redirectUri, ClientAssertion clientAssertion) { return(await ctx .AcquireTokenByAuthorizationCodeCommonAsync(authorizationCode, redirectUri, new ClientKey(clientAssertion), null).ConfigureAwait(false)); }