Reputation: 1
I'm writing a simple application in Xamarin.Forms that allows users the authentication through socials such as Facebook, Google, Instagram, Twitter, etc. I'm using Xamarin.auth to do this. I have a problem with Facebook Login. I used the same code reported in the official guide:
https://components.xamarin.com/gettingstarted/xamarin.auth
But after the application has requested the user for credentials, the response (in the code, t.Result.GetResponseText(), section 3) is a json contains the Facebook user name and surname, and a field called "id". Instead, I need all profile informations of the user, such as age, gender, etc. I suppose that I have to use the id returned for build an http request to a facebook service for retrieve data from the id.
Upvotes: 0
Views: 532
Reputation: 156
You need to specify in your facebook link the requiered fields.
Example:
var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me?fields=email,first_name,last_name,gender,picture"), null, eventArgs.Account);
After how I Get the fields
var response = await request.GetResponseAsync();
var obj = JObject.Parse(response.GetResponseText());
var id = obj["id"].ToString().Replace("\"", "");
var name = obj["first_name"].ToString().Replace("\"", "");
var lastName = obj["last_name"].ToString().Replace("\"", "");
var email = obj["email"].ToString().Replace("\"", "");
Upvotes: 2