Skip to content

Instantly share code, notes, and snippets.

@christopherhouse
Created December 13, 2013 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christopherhouse/7949492 to your computer and use it in GitHub Desktop.
Save christopherhouse/7949492 to your computer and use it in GitHub Desktop.
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