Back

can oAuth be added to an account retroactively?

  • 0
  • Users
  • Accounts
Drake
1 Sep, 2023, 03:40

oauth is matched up via email so if a user was created wiht accoutn.create() and then they later log in with oauth2, it will match up as long as the emails match up.

TL;DR
User is asking if oAuth can be added to an account retroactively. They are confused about how sessions and identifiers work in version 1.4 of the tech stack they are using. They mention using raw HTML/js for some account verification. They also mention integrating Discord roles and mapping Discord accounts to the product accounts. They are unsure if oAuth login is possible if the email used for the Appwrite account is different from the Discord account. A solution is mentioned, where the oauth API can replace the regular email session with the oauth session if the user already has a session. The key is to ensure that the emails match up. They
Tanner Meade
1 Sep, 2023, 03:44

So there is a way to retroactively add oAuth to an existing account and that will allow both email or oAuth login after it is added?

Drake
1 Sep, 2023, 03:44

nothing is really added. the account is looked up via email

Tanner Meade
1 Sep, 2023, 03:45

oh, so discord shares the discord account's email with us and that is what we used to match with the appwrite account?

Tanner Meade
1 Sep, 2023, 03:46

So then its also impossible to oAuth login a user if they used a different email for the Appwrite account than their discord account?

Tanner Meade
1 Sep, 2023, 03:48

if so, then I'll probably have to create my own oAuth to assosiate a discord account with their appwrite account.

Drake
1 Sep, 2023, 04:15

For now, kind of sort of right ๐Ÿ˜…

Drake
1 Sep, 2023, 04:16

What exactly are you trying to do?

Tanner Meade
1 Sep, 2023, 04:51

We are using discord as the primary community for our product and there are several reasons why we would need to map their appwrite account to their discord account (add custom roles to their account based on the product, and such).

Tanner Meade
1 Sep, 2023, 04:53

In order to make a solution for that, we need the basic concept of mapping their discord to their product account. Without that no functionality can happen, and we should be able to handle a situation where their existing discord account uses a different email than their product account.

Drake
1 Sep, 2023, 04:55

Add custom roles to their discord account?

What's the tech stack for your app?

What version of Appwrite do you have?

Tanner Meade
1 Sep, 2023, 05:00

Discord roles

Tanner Meade
1 Sep, 2023, 05:01

V1.3.8

Drake
1 Sep, 2023, 05:03

And tech stack for your app?

Tanner Meade
1 Sep, 2023, 05:03

Appwrite on backend and Flutter frontend mostly right now.

Drake
1 Sep, 2023, 05:04

Flutter mobile or web?

Tanner Meade
1 Sep, 2023, 05:04

Both

Tanner Meade
1 Sep, 2023, 05:05

But we use raw HTML/js for some things like account verification.

Tanner Meade
1 Sep, 2023, 05:05

So we can integrate whatever frontend needs we have.

Drake
1 Sep, 2023, 05:08

Hmm okay.

Well, the oauth API actually has a feature where if the user already has a session and then they create an oauth session, their current session will be replaced with the oauth session and they'll have the same account. So, then, you can use that oauth session (with the access token) and do whatever against discord.

In 1.4 we introduced identities that leverages this to actually save that discord account as another identifier for that account

Drake
1 Sep, 2023, 05:09

They must have a session cookie for this to work

Drake
1 Sep, 2023, 05:10

If they created an email session in a mobile flutter app and then try to create an oauth2 session, the context where the oauth2 session gets created won't have the email session

Tanner Meade
1 Sep, 2023, 05:25

We'll be upgrading to 1.4 once it's been trial tested a bit more (maybe a bug fix release or 2 more). So this is within the scope of our tech stack.

Tanner Meade
1 Sep, 2023, 05:25

I need to figure out how the newer sessions and identifiers work in 1.4.

Tanner Meade
1 Sep, 2023, 05:28

Not 100% following this yet. So someone who is logged in with a regular email session, who then creates an oAuth2 session will not create an additional identifier for the email session's appwrite account?

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