Created
March 24, 2014 09:35
-
-
Save vgheri/9737178 to your computer and use it in GitHub Desktop.
Verify Facebook Access Token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task<FacebookUserViewModel> VerifyFacebookAccessToken(string accessToken) | |
{ | |
FacebookUserViewModel fbUser = null; | |
var path = "https://graph.facebook.com/me?access_token=" + accessToken; | |
var client = new HttpClient(); | |
var uri = new Uri(path); | |
var response = await client.GetAsync(uri); | |
if (response.IsSuccessStatusCode) | |
{ | |
var content = await response.Content.ReadAsStringAsync(); | |
fbUser = Newtonsoft.Json.JsonConvert.DeserializeObject<FacebookUserViewModel>(content); | |
} | |
//var response = await client.GetStringAsync(uri); | |
//if () | |
//{ | |
// fbUser = Newtonsoft.Json.JsonConvert.DeserializeObject<FacebookUserViewModel>(response); | |
//} | |
return fbUser; | |
} | |
public class FacebookUserViewModel | |
{ | |
[JsonProperty("id")] | |
public string ID { get; set; } | |
[JsonProperty("first_name")] | |
public string FirstName { get; set; } | |
[JsonProperty("last_name")] | |
public string LastName { get; set; } | |
[JsonProperty("username")] | |
public string Username { get; set; } | |
[JsonProperty("email")] | |
public string Email { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment