/// <summary> /// Signs in using a workplace token /// </summary> /// <returns></returns> public async Task <TokenHolder> SignInWithWorkplaceCredentialsAsync(string clientId, string clientSecret, string scopes) { var loginHandler = new ClientCredentialsHandler( _httpClient, clientId.ToSecureString(), clientSecret.ToSecureString(), scopes); var tokens = await loginHandler.AuthenticateAsync(); _openIdRenewalHandler = new OpenIdRenewalHandler(_httpClient, tokens, loginHandler, _logger); _logger.LogInformation("Successfully signed in with client (workplace) credentials"); return(tokens); }
/// <summary> /// Signs in using the provided credentials /// </summary> /// <returns></returns> public async Task <TokenHolder> SignInWithUserPasswordAsync(SecureString login, SecureString password) { var loginHandler = new ResourceOwnerPasswordHandler( _httpClient, login, password); var tokens = await loginHandler.AuthenticateAsync(); _openIdRenewalHandler = new OpenIdRenewalHandler(_httpClient, tokens, loginHandler, _logger); _logger.LogInformation("Successfully signed in with user credentials"); return(tokens); }
/// <summary> /// Creates API client /// </summary> /// <remarks>The HTTP client used to construct the API client, must not automatically follow redirects!</remarks> /// <param name="client"></param> /// <param name="tokenRenewalHandler"></param> /// <param name="logger"></param> public ApiClient(HttpClient client, ITokenRenewalHandler tokenRenewalHandler, ILogger logger) : this(client, logger) { _openIdRenewalHandler = tokenRenewalHandler; }
/// <summary> /// Creates API client with a set of tokens for authentication. /// If refresh_token is provided, it will be used for token renewal. /// </summary> /// <remarks>The HTTP client used to construct the API client, must not automatically follow redirects!</remarks> /// <param name="client"></param> /// <param name="tokens">a set of tokens to use for authenticaton and renewal</param> /// <param name="logger"></param> public ApiClient(HttpClient client, TokenHolder tokens, ILogger logger) : this(client, logger) { _openIdRenewalHandler = new OpenIdRenewalHandler(client, tokens, null, _logger); }