public ClientKey(ClientAssertion clientAssertion) { if (clientAssertion == null) { throw new ArgumentNullException("clientAssertion"); } this.Assertion = clientAssertion; this.ClientId = clientAssertion.ClientId; this.HasCredential = true; }
/// <summary> /// Acquires security token from the authority. /// </summary> /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param> /// <param name="clientAssertion">The client assertion to use for token acquisition.</param> /// <returns>It contains Access Token and the Access Token's expiration time. Refresh Token property will be null for this overload.</returns> public async Task <AuthenticationResult> AcquireTokenAsync(string resource, ClientAssertion clientAssertion) { return(await this.AcquireTokenForClientCommonAsync(resource, new ClientKey(clientAssertion))); }
/// <summary> /// Acquires security token without asking for user credential. /// </summary> /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param> /// <param name="clientAssertion">The client assertion to use for token acquisition.</param> /// <param name="userId">Identifier of the user token is requested for. This parameter can be <see cref="UserIdentifier"/>.Any.</param> /// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time. If acquiring token without user credential is not possible, the method throws AdalException.</returns> public async Task <AuthenticationResult> AcquireTokenSilentAsync(string resource, ClientAssertion clientAssertion, UserIdentifier userId) { return(await this.AcquireTokenSilentCommonAsync(resource, new ClientKey(clientAssertion), userId, null)); }
/// <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="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> /// <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, Refresh Token and the Access Token's expiration time.</returns> public async Task <AuthenticationResult> AcquireTokenByAuthorizationCodeAsync(string authorizationCode, Uri redirectUri, ClientAssertion clientAssertion, string resource) { return(await this.AcquireTokenByAuthorizationCodeCommonAsync(authorizationCode, redirectUri, new ClientKey(clientAssertion), resource)); }
public async Task<AuthenticationResultProxy> AcquireTokenAsync(string resource, ClientAssertion clientAssertion, string userAssertion) { if (CallSync) { return RunTask(() => this.context.AcquireToken(resource, clientAssertion, (userAssertion == null) ? null : new UserAssertion(userAssertion))); } return await RunTaskAsync(this.context.AcquireTokenAsync(resource, clientAssertion, (userAssertion == null) ? null : new UserAssertion(userAssertion))); }
public async Task<AuthenticationResultProxy> AcquireTokenByAuthorizationCodeAsync(string authorizationCode, Uri redirectUri, ClientAssertion credential, string resource) { if (CallSync) return RunTask(() => this.context.AcquireTokenByAuthorizationCode(authorizationCode, redirectUri, credential, resource)); return await RunTaskAsync(this.context.AcquireTokenByAuthorizationCodeAsync(authorizationCode, redirectUri, credential, resource)); }
public async Task<AuthenticationResultProxy> AcquireTokenSilentAsync(string resource, ClientAssertion clientAssertion, UserIdentifier userId) { if (CallSync) return RunTask(() => this.context.AcquireTokenSilent(resource, clientAssertion, userId)); return await RunTaskAsync(this.context.AcquireTokenSilentAsync(resource, clientAssertion, userId)); }
public async Task<AuthenticationResultProxy> AcquireTokenByRefreshTokenAsync(string refreshToken, ClientAssertion credential, string resource) { if (CallSync) return RunTask(() => this.context.AcquireTokenByRefreshToken(refreshToken, credential, resource)); return await RunTaskAsync(this.context.AcquireTokenByRefreshTokenAsync(refreshToken, credential, resource)); }
/// <summary> /// Acquires security token from the authority. /// </summary> /// <param name="ctx">Authentication context instance</param> /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param> /// <param name="clientAssertion">The client assertion to use for token acquisition.</param> /// <returns>It contains Access Token and the Access Token's expiration time. Refresh Token property will be null for this overload.</returns> public static async Task <AuthenticationResult> AcquireTokenAsync(this AuthenticationContext ctx, string resource, ClientAssertion clientAssertion) { return(await ctx.AcquireTokenForClientCommonAsync(resource, new ClientKey(clientAssertion)) .ConfigureAwait(false)); }
/// <summary> /// Acquires an access token from the authority on behalf of a user. It requires using a user token previously received. /// </summary> /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param> /// <param name="clientAssertion">The client assertion to use for token acquisition.</param> /// <param name="userAssertion">The user assertion (token) to use for token acquisition.</param> /// <returns>It contains Access Token and the Access Token's expiration time.</returns> public async Task<AuthenticationResult> AcquireTokenAsync(string resource, ClientAssertion clientAssertion, UserAssertion userAssertion) { return await this.AcquireTokenOnBehalfCommonAsync(resource, new ClientKey(clientAssertion), userAssertion); }
/// <summary> /// Acquires security token without asking for user credential. /// </summary> /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param> /// <param name="clientAssertion">The client assertion to use for token acquisition.</param> /// <param name="userId">Identifier of the user token is requested for. This parameter can be <see cref="UserIdentifier"/>.Any.</param> /// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time. If acquiring token without user credential is not possible, the method throws AdalException.</returns> public async Task<AuthenticationResult> AcquireTokenSilentAsync(string resource, ClientAssertion clientAssertion, UserIdentifier userId) { return await this.AcquireTokenSilentCommonAsync(resource, new ClientKey(clientAssertion), userId); }
/// <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="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> /// <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, Refresh Token and the Access Token's expiration time.</returns> public async Task<AuthenticationResult> AcquireTokenByAuthorizationCodeAsync(string authorizationCode, Uri redirectUri, ClientAssertion clientAssertion, string resource) { return await this.AcquireTokenByAuthorizationCodeCommonAsync(authorizationCode, redirectUri, new ClientKey(clientAssertion), resource); }
/// <summary> /// Acquires security token from the authority. /// </summary> /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param> /// <param name="clientAssertion">The client assertion to use for token acquisition.</param> /// <returns>It contains Access Token and the Access Token's expiration time. Refresh Token property will be null for this overload.</returns> public async Task<AuthenticationResult> AcquireTokenAsync(string resource, ClientAssertion clientAssertion) { return await this.AcquireTokenForClientCommonAsync(resource, new ClientKey(clientAssertion)); }
/// <summary> /// Acquires an access token from the authority on behalf of a user. It requires using a user token previously received. /// </summary> /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param> /// <param name="clientAssertion">The client assertion to use for token acquisition.</param> /// <param name="userAssertion">The user assertion (token) to use for token acquisition.</param> /// <returns>It contains Access Token and the Access Token's expiration time.</returns> public async Task <AuthenticationResult> AcquireTokenAsync(string resource, ClientAssertion clientAssertion, UserAssertion userAssertion) { return(await this.AcquireTokenOnBehalfCommonAsync(resource, new ClientKey(clientAssertion), userAssertion).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="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, Refresh Token and the Access Token's expiration time.</returns> public async Task <AuthenticationResult> AcquireTokenByAuthorizationCodeAsync(string authorizationCode, Uri redirectUri, ClientAssertion clientAssertion) { return(await this.AcquireTokenByAuthorizationCodeCommonAsync(authorizationCode, redirectUri, new ClientKey(clientAssertion), null).ConfigureAwait(false)); }
public async Task<AuthenticationResultProxy> AcquireTokenAsync(string resource, ClientAssertion credential) { return await RunTaskAsync(this.context.AcquireTokenAsync(resource, credential)); }