Back

createOauth2Session gives error 409 Conflict if user already exists but logged out

  • 1
  • Accounts
  • Web
  • Cloud
Drake
26 Dec, 2023, 18:24

No. Having the identity there with the user id matching is the expected

TL;DR
Issue: When using the createOauth2Session function, an error occurs (409 Conflict) if the user already exists but is logged out. Solution: Two possible solutions have been suggested by users in the thread. 1. Way 1: Open the app, login with a different user using email and password (not oauth2), logout that user (which clears all cookies and local storage related to the user), and then login with oauth2. This should resolve the conflict and allow the oauth2 session to be created. 2. Way 2: Delete the specific session related to the user from the appwrite console. This can be
Drake
26 Dec, 2023, 18:28

Does the user have any other sessions active?

sswastik02
26 Dec, 2023, 18:29

Nope, no sessions

sswastik02
26 Dec, 2023, 18:31

not after the deleteSession step.

Drake
26 Dec, 2023, 19:53

And the emails match up between the account and the identity?

Drake
26 Dec, 2023, 21:25

Let's try this...take note of all the user identity details. Then, delete the user identity, sessions, and the user itself. Then, try to create an oauth2 session again. It should create another identity. Please compare the details between the new identity and the previous one. Do the details match?

xue
26 Dec, 2023, 23:54

i have the same issue. when i got this 409 error, i bypass like that.

WAY 1: 1-open your app 2- login with another user with email and password not oauth2 3- logout user (it clears all cookies and localstorage about user) 4- login with oauth2, it should work

WAY 2: if you delete directly exact session from appwrite console with related user, it should bypass this error message as well.

Problem: i guess browser saves some local storage and cookies, and appwrite has session with that logged in. While testing it you are trying to create session with oauth2 again and it conflicts with session that is already created. So, please clear all sessions and start to try again

sswastik02
27 Dec, 2023, 04:25

Yup they do

sswastik02
27 Dec, 2023, 04:49

I performed the steps as you mentioned, The identities of before and after differ by userId.

Drake
27 Dec, 2023, 04:49

How about the provider uid?

sswastik02
27 Dec, 2023, 04:50

They match

Drake
27 Dec, 2023, 04:51

Okay so google is always returning the same provider user id...then Appwrite shouldn't be trying to create another user or identity πŸ˜΅β€πŸ’«

sswastik02
27 Dec, 2023, 04:51

Way 1 is out of scope for me, As I do not want emailSession I have been doing way 2, but still getting conflict.

sswastik02
27 Dec, 2023, 04:54

But it should after the deletion of identity right ? It doesn't create another identity though if we call on it. I think

sswastik02
27 Dec, 2023, 04:55

It's like after logout, appwrite just tries to create a user regardless of identity

Drake
27 Dec, 2023, 05:13

After you deleted and signed in again, a new user and Identity were created. After that, it should lookup the previous user and Identity

Drake
27 Dec, 2023, 05:13

It would only do that if it can't match on email/provider user id

sswastik02
27 Dec, 2023, 05:16

Right, I feel however that condition is being disregarded. It is just going on to create a user.

Drake
27 Dec, 2023, 05:18

So, again, you only have 1 identity in your project? How many users?

Drake
27 Dec, 2023, 05:19

And if you call account.get() before the create oauth2 session, it throws an exception?

sswastik02
27 Dec, 2023, 05:24

Many anonymous users, 4 identities, becuase I used Oauth with 4 different accounts

Drake
27 Dec, 2023, 05:25

Can you delete all identities and users?

sswastik02
27 Dec, 2023, 05:26

I do actually, I get the guest scope right after logout and before createOauthSession.

sswastik02
27 Dec, 2023, 05:26

Ok doing it now, Is there a way to bulk delete from appwrite cli ?

Drake
27 Dec, 2023, 05:33

Maybe some bash + jq magic

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