Created
December 13, 2013 19:09
-
-
Save christopherhouse/7949492 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 System.Net.Http; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json.Linq; | |
using ThirteenDaysAWeek.AzureCustomAuth.Services; | |
namespace ThirteenDaysAWeek.AzureCustomAuth.Handlers | |
{ | |
public class AuthenticationHandler : DelegatingHandler | |
{ | |
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | |
{ | |
var response = await base.SendAsync(request, cancellationToken); | |
response.EnsureSuccessStatusCode(); | |
string jsonString = await response.Content.ReadAsStringAsync(); | |
JObject jsonObject = JObject.Parse(jsonString); | |
string token = jsonObject["token"].ToString(); | |
AccountService.AuthenticationToken = token; | |
return response; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment