#Google and Apple sign in

28 messages · Page 1 of 1 (latest)

pallid star
#

How to get user data like name, photo Url, email, number after signing in with Google or Apple. So I can create a user table with these data

timid breach
#

With a function triggered on user creation

safe oyster
#

I think the OP wants to fetch those from the OAuth Provider if I am not wrong.

timid breach
#

I think it will not be possible to get that directly from the oAuth provider (at least in most cases) due to privacy and security reasons

pallid star
#

There are some websites that use Google data though

timid breach
pallid star
#

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

timid breach
pallid star
#

In appwrite

timid breach
#

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

pallid star
#

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

#

How do you get name and email from google auth

timid breach
#

Appwrite gets it and creates an account

#

You get it from the account created

pallid star
#

Does it also get the photourl

timid breach
#

Nope

#

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

pallid star
#

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

timid breach
#

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
#

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

pallid star
#

Yes yes

timid breach
#

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)

#

Also I recommend triggering it in async mode

pallid star
#

Same for apple oauth right.?

timid breach
#

Yes, same for all oAuth and even email registering

sly pecan
pallid star