Back

[SOLVED] Device authorization flow (social auth)

  • 0
  • Flutter
Drake
23 May, 2023, 23:06

this is the endpoint that takes the auth code, requests an access token, and then creates an appwrite session: https://github.com/appwrite/appwrite/blob/master/app/controllers/api/account.php#L376-L400

TL;DR
I had trouble getting an id token from Google sign in, but I found a serverAuthCode property that might work. I tested it and it does work to exchange the device token for an Appwrite oauth2 session. The only issue was that I forgot to include the project ID, but I found the solution for that. The Github link I provided earlier was incorrect, but I found the correct function. The issue was that the OAuth2 provider in Appwrite was not enabled. I suggested using the API instead of writing PHP code. The problem is now solved.
Drake
25 May, 2023, 01:12

did you get a chance to try it out? 🧐

Adevien
25 May, 2023, 01:13

not yet, will find some time though my php skills are not the greatest 😄

Drake
25 May, 2023, 01:17

Oh I was just suggesting to use the API, not write any php code

Adevien
25 May, 2023, 01:18

oh, how dumb of me, lol

joeyouss
25 May, 2023, 18:35

[SOLVED] Device authorization flow (social auth)

Adevien
27 May, 2023, 00:25

did more research and managed an attempt to test the request but

Adevien
27 May, 2023, 00:25

it says the provider is not enabled 🤔

Adevien
27 May, 2023, 00:25

am i missing something?

Drake
27 May, 2023, 00:31

how did you make the request?

Either the OAuth2 provider in Appwrite isn't enabled or the project ID is incorrect

Adevien
27 May, 2023, 00:31

i ... found the issue

Adevien
27 May, 2023, 00:32

the github link is to the wrong function 😂

Drake
27 May, 2023, 01:18

huh?

Adevien
27 May, 2023, 01:19

the request you linked had no projectId param

Adevien
27 May, 2023, 01:19

the above has it

Adevien
27 May, 2023, 01:19

was my bad there 😂

Drake
27 May, 2023, 01:20

oh, sorry. you can send it as a query string like the one you linked does

Adevien
27 May, 2023, 01:20

yes it works, i just assumed there was no need for projectid (dumb of me)

Drake
27 May, 2023, 01:21

it works as in you can exchange the device token for an appwrite oauth2 session?

Adevien
27 May, 2023, 01:21

haven't got to test with actual session only mockup

Drake
27 May, 2023, 01:21

ah okay

Adevien
27 May, 2023, 01:22

im a bit squeezed between deadlines so i can only put like 5-10 mins

Adevien
27 May, 2023, 01:22

😦

Drake
9 Jun, 2023, 13:16

Ugh....I couldn't get Google sign in to return an id token, but as I was testing, I noticed a serverAuthCode property. Maybe that can be passed to Appwrite to create the oauth2 session 🧐

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