Created
April 26, 2016 12:53
-
-
Save MisterJames/6a2ee9918afa9019aa3c1891f216102a to your computer and use it in GitHub Desktop.
CreatingGitHubAuthTicket
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 static async Task CreatingGitHubAuthTicket(OAuthCreatingTicketContext context) | |
{ | |
// Get the GitHub user | |
var request = new HttpRequestMessage(HttpMethod.Get, context.Options.UserInformationEndpoint); | |
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", context.AccessToken); | |
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); | |
var response = await context.Backchannel.SendAsync(request, context.HttpContext.RequestAborted); | |
response.EnsureSuccessStatusCode(); | |
var user = JObject.Parse(await response.Content.ReadAsStringAsync()); | |
AddClaims(context, user); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment