Created
May 8, 2015 20:48
-
-
Save vman/11dd0131bbbf8803c859 to your computer and use it in GitHub Desktop.
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
using (var client = new HttpClient()) | |
{ | |
//Enable signon and read users' profile | |
using (var request = new HttpRequestMessage(HttpMethod.Get, "https://graph.microsoft.com/beta/me")) | |
{ | |
request.Headers.Add("Authorization", "Bearer " + token); | |
request.Headers.Add("Accept", "application/json;odata.metadata=minimal"); | |
using (var response = client.SendAsync(request).Result) | |
{ | |
if (response.StatusCode == HttpStatusCode.OK) | |
{ | |
var json = JObject.Parse(response.Content.ReadAsStringAsync().Result); | |
ViewBag.CurrentUserDisplayName = json["displayName"].ToString(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment