https://serverless-stack.com/ logo
#help
Title
# help
g

Garret Harp

05/16/2022, 10:10 PM
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

Garret Harp

05/17/2022, 1:38 AM
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

manitej

05/17/2022, 1:40 AM
Do you have both email and google login in your userpool?
g

Garret Harp

05/17/2022, 1:41 AM
Yes
m

manitej

05/17/2022, 1:45 AM
gotcha, will check that
g

Garret Harp

05/17/2022, 1:59 AM
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

manitej

05/17/2022, 2:32 AM
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

Garret Harp

05/17/2022, 2:33 AM
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

Frank

05/18/2022, 5:18 AM
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

manitej

05/18/2022, 5:20 AM
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.