I cannot get a users email when i use facebook login

I can only get the users name and id. How do I get their email so that I can check if they’ve already created a local account,

I’ve tried setting the permissions to this.
{ permissions: [‘public_profile’, ‘email’] }

I personally haven’t used the Facebook API but it looks like you’ll have to leverage the token you receive from the logInWithReadPermissionsAsync() https://docs.expo.io/versions/latest/sdk/facebook.html#example with Facebook’s Graph API to fetch the user’s email. https://developers.facebook.com/docs/graph-api/reference/user/

I may be mistaken so someone who has experience using the API may be able to provide better insight.

thankyou, i’m doing that but i only get the users name and id

1 Like

I see. Sorry I couldn’t be of more assistance. Did some quick perusing on SO and some people have mentioned the necessity to add 'email' to the scope property (Note: The post was from last year but may still be applicable unless the Graph API changed). Others have noted that if the user hasn’t verified the e-mail through Facebook’s verification process, the Graph API won’t pass the email value even if your app has been granted permission to read said email.

Putting email to permissions doesn’t help. You have to add &fields=email,gender,name to your graph query url.

2 Likes

You need to make your fetch API call this:

  const response = await fetch(
    `https://graph.facebook.com/me?fields=id,name,email,birthday&access_token=${token}`);
6 Likes

const response = await fetch(
https://graph.facebook.com/me?fields=id,name,email,birthday&access_token=${token});

how to get contact number ?