Files
cms_thermo_active/Step/Provider/SignalROAuthBearerProvider.cs
T
Paolo Possanzini 3d7571f000 Primo commit
2017-11-15 17:36:25 +01:00

31 lines
785 B
C#

using Microsoft.Owin.Security.OAuth;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
namespace Groupadoo.Web.Providers
{
public class SignalROAuthBearerProvider : OAuthBearerAuthenticationProvider
{
public override Task RequestToken(OAuthRequestTokenContext context)
{
var token = context.OwinContext.Request.Query["bearer_token"];
if (!string.IsNullOrWhiteSpace(token))
{
var result = JsonConvert.DeserializeObject<TokenValue>(token);
if (context != null && result != null)
context.Token = result.token;
}
return Task.FromResult<object>(null);
}
}
class TokenValue
{
public string token { get; set; }
}
}