How do I confirm a user account in Amazon Cognito?

3 minute read
0

I want to confirm a user account in Amazon Cognito.

Resolution

There are two ways to confirm a user account in Amazon Cognito:

  • Through email or phone number verification
  • Through the administrator

Both of these options set the user status to CONFIRMED.

Email or phone number verification

Configure your Amazon Cognito user pool to require that users provide an email address or phone number when they sign up. Amazon Cognito then sends a verification code to that email address or phone number to confirm the user account.

By providing the verification code, the user proves that they have access to the mailbox or phone that received the code. After the user provides the code, Amazon Cognito does the following:

  • Sets the user status to CONFIRMED.
  • Updates the user attributes to indicate that the email address or phone number is verified.

For information on how to choose the user contact attribute that Amazon Cognito sends a verification message to, see Verifying contact information at sign-up.

Note: If you receive errors when running AWS Command Line Interface (AWS CLI) commands, make sure that you’re using the most recent AWS CLI version.

AWS CLI commands:

Signup

aws cognito-idp sign-up --client-id 3n4b5urk1ft4fl3mg5e62d9ado --username testuser --password PASSWORD --user-attributes Name="email",Value="jane@example.com" Name="name",Value="Jane"

Output

{
  "UserConfirmed": false,
  "UserSub": "e04d60a6-45dc-441c-a40b-e25a787d4862"
}

Confirm signup

aws cognito-idp confirm-sign-up --client-id 3n4b5urk1ft4fl3mg5e62d9ado --username testuser --confirmation-code CONF_CODE

Note: You must pass --secret-hash in the CLI command if you meet both of the following requirements:

  • Your AWS CLI commands have --client-id as a parameter.
  • The app client is configured with a secret.

To calculate the secret hash of an app client, see [How do I troubleshoot "Unable to verify secret hash for client

" errors from my Amazon Cognito user pools API?](https://repost.aws/knowledge-center/cognito-unable-to-verify-secret-hash)

Administrator verification

To confirm a user account through administrator verification, use the Amazon Cognito console, or use the AWS CLI API command.

Use the Amazon Cognito console:

  1. Open the Amazon Cognito console.
  2. From the navigation pane, choose User Pools, and then select your user pool.
  3. Choose the Users tab, and then select the user that you want to confirm.
  4. In the user information page, choose Actions, and then select Confirm Account.

Use the AWS CLI command:

aws cognito-idp admin-confirm-sign-up --user-pool-id us-west-2_aaaaaaaaa --username testuser

AWS OFFICIAL
AWS OFFICIALUpdated a year ago