amazon-archives / amazon-cognito-auth-js

The Amazon Cognito Auth SDK for JavaScript simplifies adding sign-up, sign-in with user profile functionality to web apps.
Apache License 2.0
424 stars 232 forks source link

Social Login Always Create New Users #190

Open rhidajat opened 5 years ago

rhidajat commented 5 years ago

I have existing users in my user pool and now I want to allow them to sign in using social Login, in this case Google. My problem is that whenever users signs in with their Google account, cognito does not map the google email address to existing user with that email address, thus it will create a different user altogether.

Can anyone confirm that Cognito does not support mapping to existing users? Or am I missing something here?

I have set the Attribute Mapping to map Google's email to Cognito's email field.

mymattcarroll commented 5 years ago

You can use CognitoIdentityServiceProvider.adminLinkProviderForUser: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#adminLinkProviderForUser-property

rhidajat commented 5 years ago

@mymattcarroll, thanks for the pointer! I am gonna give it a try!