user3348354
user3348354

Reputation: 321

Xamarin Azure Facebook get user info

I've been searching on the best way to get information my azure auth from facebook.

My app is getting the authentication and the id of the user! I am not sure what code I need next in order to get the information.

So far I have this

if (authenticated)
{     
    var client = new HttpClient();
    var fbUser = await client.GetAsync(Appurl+".auth/me");
    var response = await fbUser.Content.ReadAsStringAsync();
    var jo = JObject.Parse(response);
    var userName = jo["'typ':'user_id'"].ToString();
}

So far all the answers have left me clueless

I just need this to return name email and other Items I want. I am sure this is an Json Parsing the wrong issue but I am not sure.

Please help!!!

Upvotes: 0

Views: 136

Answers (1)

Tom Sun
Tom Sun

Reputation: 24539

I just need this to return name email and other Items I want. I am sure this is an Json Parsing the wrong issue but I am not sure.

If you visit https://yourmobileapp .azurewebsites.net/.auth/me from browser, and login with your FaceBook account. Then you could get the Json structs as following. It is a JArray . So please have a try to use following code, it works correctly on my side.

  var ja = JArray.Parse(response);
  var id = ja[0]["user_id"];

enter image description here

Before that we need to add email scope on the Azure portal, about how to add email scope, please refer to the screenshot.

enter image description here

Upvotes: 1

Related Questions