Handle same user from diff. IDPs w/ AWS Cognito: best practice!

Issue

AWS Cognito creates multiple entries in the user pool when signing in a user with the same email address through the Google and Facebook identity providers. How can I create just one user instead of multiple users and is it possible to automatically combine the entries with AWS Cognito or with AWS Lambda functions?

Example Code

The following example code was used to set up AWS Cognito: The Complete Guide to User Authentication with the Amplify Framework

Example code

Screenshot

Screenshot of AWS Cognito user pool

To create just one user instead of multiple users when signing in a user with the same email address through the Google and Facebook identity providers, you need to enable the same email address in the user pool settings. This can be done by following these steps:

  1. Go to your AWS Cognito user pool dashboard.
  2. Click on “Attributes” in the left-hand menu.
  3. Find the “Email” attribute and click “Edit”.
  4. Check the box next to “Same user can have multiple email addresses”.
  5. Click “Save changes”.

Once this is done, AWS Cognito will allow multiple sign-ins with the same email address and will merge the entries automatically. No additional code or Lambda functions are necessary.