Problem with facebook integration using Expo


#1

My piece of code shown below:

fbSocialLogin = async () => {
try {
const { type, token } = await Facebook.logInWithReadPermissionsAsync(
“582284132122368”,
{ permissions: [‘email’, ‘public_profile’] }
);
switch (type) {
case “success”: {
console.log(token);
const response = await fetch(https://graph.facebook.com/me?access_token=${token});
const profile = await response.json();
console.log(JSON.stringify(profile));
return profile;
break;
}
case “cancel”: {
return “cancel”;
break;
}
default: {
return “failed”;
}
}
} catch (error) {
alert(error.message);
}
};

It return only name and id params but according to permission its not return full response please help me sort out this problem …


#2

Hey @kulbhushansingh,

I would suggest reading through the Facebook Graph API docs so you can better understand how to fetch things: https://developers.facebook.com/docs/graph-api

For instance, if you wanted to get a user’s name and picture your fetch should look like this fetch(https://graph.facebook.com/me?access_token=${token}&fields=id,name,picture.type(large)) with the added fields parameters.

Cheers,

Adam


closed #3

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.