Has anyone here setup cognito with google login? I...
# help
g
Has anyone here setup cognito with google login? I am trying to ensure that only one account will ever exist for a user so whenever someone tries to login with google if they do not already have a cognito native account I will create one and then link them but for some reason I get an error on the login that user already exists so I have to double login. Not sure how to go about fixing this, anyone know?
g
I mean more specifically how to stop needing to double login, I assume this is happening because I am linking the account to the normal cognito account of the same email. But I get the following error back:
error_description=Already+found+an+entry+for+username+5gRxMfZldCqOpmyuDkI7ejfbUmONTvk%2F%2BFJxxbu7W0M%3D+&error=invalid_request
m
Do you have both email and google login in your userpool?
g
Yes
m
gotcha, will check that
g
I'm assuming theres probably no way to fix it since I link them in presignup and since the user will now technically exists since I link it to one cognito wont be happy with that
m
I think you can do it with the help of
pre-signup
trigger, the way i'd do is create a proxy lambda for pre-signup trigger and check if the user exists from the event and merge them if exists.
g
Well that is what I do and it does merge the accounts correctly but I get the error thrown that a user already exists and I have to login again. Which when I login again all is good and cognito is happy again.
f
Hey @Garret Harp, let us know if you figure it out. We will add it to the doc. I’m sure many others will find this useful.
m
I'm trying to make a tutorial
@Garret Harp seems like there's no workaround yet for this, we need to restart the sign-in process again when the user registers for the first time using OAuth.