Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.
final String clientId = "XXXXXXXXXXXXXXXXXXXXXXXXX";
final String region = "eu-west-1";
final String username = "USERNAME";
final String password = "PASSWORD";
AWSCognitoIdentityProvider cognitoClient = AWSCognitoIdentityProviderClientBuilder.standard()
.withRegion(region)
.build();
final Map<String, String> authParams = new HashMap<>();
authParams.put("USERNAME", username);
authParams.put("PASSWORD", password);
final InitiateAuthRequest authRequest = new InitiateAuthRequest();
authRequest.withAuthFlow(AuthFlowType.USER_SRP_AUTH)
.withClientId(clientId)
.withAuthParameters(authParams);
InitiateAuthResult result = cognitoClient.initiateAuth(authRequest);
Background story
We would like to use the GetAccess Token using Client Credentials from Lambda to authenticate with Amazon Cognito
What does this example accomplish?
The example will describe how to obtain a token from Cognito using Client Credentials.
Which AWS service(s)?
cognito
Which AWS SDKs or tools?
Are there existing code examples to leverage?
https://stackoverflow.com/questions/56954135/getting-amazon-cognito-access-token-in-java
Do you have any reference code?