0

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.

1 Answers1

2

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("\"", "");
Katz
  • 156
  • 9
  • Why do i get this error ( on line - var obj = JObject.Parse(response.GetResponseText()); ) : Task does not contain a definition for GetResponseText ? – TigerLionCheetah Jun 29 '17 at 20:23
  • Because maybe you define the variable "response" like a Task and Task not contain any definition for GetReponseText method, so you need to define the "response" variable like a Response type. – Katz Jul 01 '17 at 23:16