Back

Google and Apple sign in

  • 1
  • Users
  • Flutter
  • Accounts
frankenstein
12 Oct, 2023, 06:40

So I have to create another form for filling in these details.??

TL;DR
The user is discussing how to handle the situation of sign-in with Google and Apple. They suggest creating an OAuth session and fetching the access token to make API calls and fetch other information. There is a recommendation to trigger it in async mode and a mention of using an appwrite account creation action. The user also mentions that if the document ID is set as the user ID, it will not duplicate data. They share their own method of handling the sign-in process with Google. There is a question about how to fetch name and email from Google auth and a suggestion to create a new document with the fetched data. The user wants to get Google
frankenstein
12 Oct, 2023, 06:40

There are some websites that use Google data though

D5
12 Oct, 2023, 06:53

Once the user logins with Google, you can get the data from Appwrite

frankenstein
12 Oct, 2023, 06:55

I want on get Google data on sign-up so I create user table with photo url, name, email etc from google

D5
12 Oct, 2023, 06:58

You mean externally, and not in Appwrite, true?

frankenstein
12 Oct, 2023, 06:59

In appwrite

D5
12 Oct, 2023, 06:59

Then the solution is without any doubts the one I suggested you: after the user logins, you get the name, email, etc with a function and create a new document in a collection with such data

frankenstein
12 Oct, 2023, 06:59

Just like in some websites you just sign in with Google and all other info is fetched from google acc

frankenstein
12 Oct, 2023, 07:00

How do you get name and email from google auth

D5
12 Oct, 2023, 07:00

Appwrite gets it and creates an account

D5
12 Oct, 2023, 07:00

You get it from the account created

frankenstein
12 Oct, 2023, 07:01

Does it also get the photourl

D5
12 Oct, 2023, 07:02

Nope

D5
12 Oct, 2023, 07:03

Unfortunately it doesn't because if I remember well, its a sensitive scope

frankenstein
12 Oct, 2023, 07:06

Lemme check the outh2 function and see how to fetch name and email so i can put it in the users table

D5
12 Oct, 2023, 07:07

I do it this way:

  1. User clicks login with Google button
  2. If the Auth flow is correct, the function is triggered from client side
  3. In the function I get the user that triggered the function and I create with such data a new document
D5
12 Oct, 2023, 07:08

It will not duplicate data if you set document ID as user ID, since it it's an user that logins again, it will throw an error of document with an existing ID

frankenstein
12 Oct, 2023, 07:09

Yes yes

D5
12 Oct, 2023, 07:09

It's possible to do it too with appwrite account creation action, but I prefer that way 😅 (Mainly because in old appwrite versions oAuth didn't trigger that)

D5
12 Oct, 2023, 07:10

Also I recommend triggering it in async mode

frankenstein
12 Oct, 2023, 07:10

Same for apple oauth right.?

D5
12 Oct, 2023, 07:11

Yes, same for all oAuth and even email registering

Drake
14 Oct, 2023, 23:08

After creating an oauth session, fetch the session. It should have an access token from the oauth provider. You can try using that access token to make API calls to the provider and fetch other things like profile picture

frankenstein
17 Oct, 2023, 08:35

Lemme try this one. Thanks @Steven

xue
17 Oct, 2023, 08:51

this is also my way to handle with this situation. Good luck

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