How to validate Aws cognito refreshToken is valid or not in java?

Viewed 24

I have to check whether the refresh token which we got from cognito along with access token is valid or not. Means need to check the refresh token is still active or not. Need the code snippets in java.

1 Answers

To see the latest Java V2 (Not V1 - that is no longer recommended to use) and other AWS SDK code examples, look at the brand new Code Catelog that has been released only a month or so. Its is applicable to any supported AWS SDK langangue. This content has hundreds of examples in different programming languages - including Cognito and the AWS SDK for Java v2.

There is a very detailed example for Cognito that works with tokens and authentication.

It performs these steps.

  1. Invokes the signUp method to sign up a user.
  2. Invokes the adminGetUser method to get the user's confirmation status.
  3. Invokes the ResendConfirmationCode method if the user requested another code.
  4. Invokes the confirmSignUp method.
  5. Invokes the initiateAuth to sign in. This results in being prompted to set up TOTP (time-based one-time password). (The response is “ChallengeName”: “MFA_SETUP”).
  6. Invokes the AssociateSoftwareToken method to generate a TOTP MFA private key. This can be used with Google Authenticator.
  7. Invokes the VerifySoftwareToken method to verify the TOTP and register for MFA.
  8. Invokes the AdminInitiateAuth to sign in again. This results in being prompted to submit a TOTP (Response: “ChallengeName”: “SOFTWARE_TOKEN_MFA”).
  9. Invokes the AdminRespondToAuthChallenge to get back a token.

See Sign up a user with an Amazon Cognito user pool that requires MFA using an AWS SDK

Related