/// <summary> /// Gets the Client Secret For Current Client /// </summary> /// <param name="client">The Client</param> /// <returns>The Client Secret</returns> public string GetClientSecretForCognitoClient(ConfigClientData client) { var clientSecret = CognitoClients.FirstOrDefault(x => x.UserPoolId == client.Cognito.ClientApp.UserPoolId && x.ClientId == client.Cognito.ClientApp.ClientId)?.ClientSecret; return(clientSecret); }
/// <summary> /// Gets the access token via Client Credentials OAuth 2 flow. /// </summary> /// <param name="cognitoClient">The Cognito Client.</param> /// <returns>The access token.</returns> public async Task <string> GetClientCredentialsTokenAsync(ConfigClientData cognitoClient) { var tokenResponse = await this._httpClient.RequestClientCredentialsTokenAsync( new ClientCredentialsTokenRequest { ClientId = cognitoClient.Cognito.ClientApp.ClientId, ClientSecret = cognitoClient.Cognito.ClientApp.ClientSecret, Address = cognitoClient.Cognito.TokenUrl, Scope = cognitoClient.Cognito.ClientCredentialsAuthScope }).ConfigureAwait(false); return(tokenResponse.AccessToken); }