Back

Google Oauth2 - Unable to login with 2 different emails close to each other, and no info in redirect

  • 0
  • Auth
Pingu
12 Aug, 2024, 00:18

Hey,

So when I GET v1/account/sessions/oauth2/google (I have setup google as a provider in console), I am taking to the google oauth2 consent screen. Upon success, I am redirected to the success Uri - but I sort of expected to see some info in the query parameters - what am I meant to do once they hit my success page to determine their session details etc? I assume its headers being set for them to be authenticated? I would have to get session on response then and relay that to whatever needs to handle it or something...?

Also, I am able to auth with one of my google emails, and all seems fine. but then attempting to auth with a second one a short time later sends me to:

https://cloud.appwrite.io/v1/account/sessions/oauth2/google/redirect?state=%7B%22success%22%3A%22https%3A%5C%2F%5C%2Flocalhost%3A5001%5C%2Fsuccess%22%2C%22failure%22%3A%22https%3A%5C%2F%5C%2Flocalhost%3A5001%5C%2Ffail%22%2C%22token%22%3Afalse%7D&code=......

which shows the following json message:

TypeScript
{"message":"A user with the same id, email, or phone already exists in this project.","code":409,"type":"user_already_exists","version":"1.5.8"}

However the docs suggest that it will create a new account, or match it against an existing one - And that is what it does for the first email I used.

TL;DR
Developers are struggling to log in with two different Google emails in quick succession, and are not getting any information in the redirect. The issue arises as the second email login attempt results in an error message stating a user with the same credentials already exists. The solution is to check that the OAuth flow is correctly handling account creation or matching against existing accounts as per the documentation.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more