How to Verify a Cognito User's Email

avatar

Borislav Hadzhiev

Fri Sep 24 20211 min read

banner

Photo by Ryan Moreno

Verify a Cognito User's Email #

We need to verify a cognito user's email, because otherwise they can't use the forget password and other functionality.

In order to verify a cognito user's email, we have to set their email_verified attribute to true. To set their email_verified attribute to true we can use the admin-update-user-attributes command.

shell
aws cognito-idp admin-update-user-attributes --user-pool-id YOUR_USER_POOL_ID --username john@gmail.com --user-attributes Name="email_verified",Value="true"

verify user email

We're using the admin-update-user-attributes command to verify the user's email, however it can be used to update any of the cognito user's attributes.

To make sure the email of the user is verified, run the admin-get-user command.

shell
aws cognito-idp admin-get-user --user-pool-id YOUR_USER_POOL_ID --username john@gmail.com --query "UserAttributes"

confirm email verified

The admin-get-user command returns information about the cognito user, however we've filtered the output to only show the user's attributes, by setting the --query parameter.

Once the user's email_verified attribute is set to true, they can use the forget password functionality and get emails with confirmation codes.

Further Reading #

Join my newsletter

I'll send you 1 email a week with links to all of the articles I've written that week

Buy Me A Coffee