Consuming facebook graph api


#1

I’m using the expo api to implement Facebook login in my app. The login works just fine, but when I try to access the graph api, I’m only getting the name and the id - no matter what I request.

My code is as follows -

login = async() => {
  const APP_ID = '1121020794696681';
  const options = {
    permissions: ['public_profile', 'email', 'user_friends']
  }
  const {type, token} = await Expo.Facebook.logInWithReadPermissionsAsync(APP_ID, options);
  if(type=='success') {
    const response = await fetch(`https://graph.facebook.com/v2.9/me?access_token=${token}`);
    console.log(await response.json());
    
  }
}

The output that I get in the console is -
Object {
“id”: “10211949495125019”,
“name”: “Sambhav Anand”,
}

Since I’m requesting a user object and then printing that out, why am I not getting access to all the other data in the public_profile permission


#2

This sounds like more of an issue with the Facebook API. You could try making the request with an API testing tool to double check that you’re sending the correct request.


#3

I used the same code, which is recommended by the expo docs and the response is identical to sambhavanand’s. I’m trying to get access to the email address. Can anyone help with this?


#4

I’m having this same issue. According to the Facebook docs, there should be additional data (picture, link, etc.) that comes along with the returned data. Why would this not be the case for the Expo version?

Also, I tried adding user_friends and email permissions as well, and still got only name and id back.


#5

I put together a Snack that works for me! It looks like you are missing some fields at the end of your Graph call… :sweat_smile::blue_heart:

Here is what my profile looks like:


#6

Yes, thank you @bacon! The issue was simple: I was missing the fields param at the end of the Graph API call, like so:

https://graph.facebook.com/me?access_token=${token}&fields=id,name,email,picture

I really appreciate the help :slight_smile: