-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect multiple Logins to the same User #5104
Comments
@vadiraja Have you reviewed the Social Providers and Federation setup within our documentation? |
Yes, I read it but there is no option for setting up Cognito Pool for what I am asking. If you can point me to specific section that would be helpful. |
@Mersmith Not sure if this is still an issue for you, but we implemented the following solution using the pre-sign up trigger: #369 (comment) It links the two accounts so that they share the same sub. |
@tvbowersz thanks for the link to a very helpful comment. When implementing the pre-signup trigger leveraging |
@Akshat0694 I"m not clear on where you are saying you are receiving the |
Hey @tvbowersz or @Akshat0694 , when you did the pre-sign up trigger work around, did you see a side effect that users cannot reset their cognito password anymore? I may have implemented mine slightly differently (as vaguely described here #565 where i throw an exception and retry the authentication in the frontend) so we only end up with a single linked user. |
@barticus Is the user's Also when working with external Identity Providers the The only way I know of to fix it is if you map the cognito native attribute In TS, for google oauth: this.userPoolIdentityProviderGoogle = new cognito.UserPoolIdentityProviderGoogle(
this,
"userpool-identity-provider-google",
{
userPool: this.userPool,
clientId: GOOGLE_CLIENT_ID,
clientSecret: GOOGLE_CLIENT_SECRET,
attributeMapping: {
email: {
attributeName: cognito.ProviderAttribute.GOOGLE_EMAIL.attributeName
},
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
emailVerified: {
attributeName: "email_verified"
}
}
}
); The types in the Same thing but with AWS Cloudformation: UserPoolIdentityProvider:
Type: AWS::Cognito::UserPoolIdentityProvider
Properties:
UserPoolId: !Ref CognitoUserPool
ProviderName: Google
ProviderDetails:
client_id: !Ref GoogleAppId
client_secret: !Ref GoogleAppSecret
authorize_scopes: "profile email openid"
ProviderType: Google
AttributeMapping:
email: email
given_name: given_name
family_name: family_name
email_verified: email_verified
|
@bobbyhadz hey thanks for the response! Not long after posting my question I stumbled upon another thread where they mentioned adding the attribute mapping and confirmed that it all works fine with that. I did mean to come back to this thread for any future readers but forgot about it. |
@bobbyhadz in case its helpful, this is the CDK i ended up with (and doesnt need a ts-ignore on it):
Seems strange they don't have all the provider attributes listed in the Cognito console. |
@barticus did you use this with Facebook as a provider? Just tested it with Google and it works, thanks! I have to add Facebook oauth next, so just making sure, thank you for taking the time. |
@bobbyhadz no, just with google. With FB, just a heads up that if you're using the method where you throw an error in PreSignUp (after attaching identity details) and then retry login on the frontend, it may not work as smoothly (#565 (comment)) |
Cognito has recently resolved an issue with linking federated users to an existing user profile in Cognito User Pools. As a result, your Amplify application can now merge user identities from 3rd party social identity providers to a Cognito user in a user pool using the Pre sign-up Lambda trigger. You can use the
We will work on resources to share with you to explain how to integrate this feature into your Amplify app. |
Following up here, I can confirm that this works for both Facebook and Google, where only one user is created in the scenario where the existing user is setup with username/password and you link their social logins to it. We are working on updating the documentation detailing this steps, but in the meantime, here is a sample app that uses the pre-signup trigger to merge accounts. |
Hi! Workarounds? |
HI @michelmob - have you had a chance to look at this sample code for a preSignUp lambda that will merge a users account? |
Closing this issue in favor of tracking the documentation improvement here |
I am still getting |
Hi @theewl are you trying to merge two existing users? |
Correct |
I'm trying to implement the exact same thing, except the user signs up with their phone number and password. |
** Which Category is your question related to? **
Auth
** What AWS Services are you utilizing? **
Cognito, AWS AppSync, API
** Provide additional details e.g. code snippets **
E.g. Sample code, versions of Amplify you are using
Amplify CLI - 4.12.0
"amazon-cognito-identity-js": "^3.2.5",
"aws-amplify": "^2.2.6",
"aws-amplify-react-native": "^3.2.2",
"aws-appsync": "^3.0.2",
"aws-appsync-react": "^3.0.2",
"expo": "^36.0.0",
I am using Amplify Auth for Sign in and Sign up. I have also connecter Cognito User Pools to social logins. Now the question is, if some one already signed up using username/password and then they try to use Facebook login, how do I connect both the user credentials together? Now it creates a separate account for each social login. This would be a nightmare for connecting analytics and user experience.
Can I provide a button in a profile screen for users to connect both the account? But how do I store that in Cognito user pool?
Any suggestions on how to handle it?
The text was updated successfully, but these errors were encountered: