Willie Willie - 19 days ago 6
C# Question

Facebook C# SDK not returning all information

My permission scope is defined in this:

var loginUrl = fb.GetLoginUrl(new
{
client_id = ConfigurationManager.AppSettings["facebookAppID"].ToString(),
client_secret = ConfigurationManager.AppSettings["facebookAppSecret"].ToString(),
redirect_uri = RedirectUri.AbsoluteUri,
response_type = "code",
scope = "public_profile, email, user_friends, user_about_me, user_birthday, user_education_history, user_work_history, user_location" // Add other permissions as needed
});


Then i get my access token this way:

var fb = new FacebookClient();
fb.AppId = ConfigurationManager.AppSettings["facebookAppID"].ToString();
fb.AppSecret = ConfigurationManager.AppSettings["facebookAppSecret"].ToString();

dynamic result = fb.Post("oauth/access_token", new
{
client_id = ConfigurationManager.AppSettings["facebookAppID"].ToString(),
client_secret = ConfigurationManager.AppSettings["facebookAppSecret"].ToString(),
redirect_uri = RedirectUri.AbsoluteUri,
code = code
});


Then i assign my access token to the Facebook client this way:

fb.AccessToken = accessToken;


I have a custom class to retrieve the data from Facebook SDK:

dynamic userDetails = fb.Get("me", new { fields = "name, email, gender, birthday, education, work" });
dynamic userEducation = fb.Get("me?fields=education");
//2. Store details to be used
var facebookUserDetails = new UserFacebookDetails();
facebookUserDetails.Name = userDetails.name;
facebookUserDetails.Email = userDetails.email;
facebookUserDetails.Gender = userDetails.gender;
facebookUserDetails.SetBirthDayVals(userDetails.birthday);


I get data for name, email and gender only. I don't get info on birthday, education or work. I check the same endpoint at Facebook API Explorer and i get information. What is happening? Can anyone please help me out?

Answer

I think i have figured the solution to this problem. The source of the problem stems at Facebook. I had not submitted my app for review and typically, those 3 scopes were among the set that needed submission before used.