title: Unable to Identify User Context in SignalR hub decorated with "Authorize" attribute
body: <p>Server </p>
  
  <p>SignalR hub within MVC 5 WebApi 2,
  Security: Bearer token</p>
  
  <p>Client </p>
  
  <p>C# class using HttpWebRequest to retrieve bearer token from WebApi controller /Token endpoint</p>
  
  <p>I used the pattern described <a href="https://stackoverflow.com/questions/23867640/signalr-authentication-failed-when-passing-bearer-through-query-string" title="Stack Overflow">here</a> and <a href="http://geekswithblogs.net/shaunxu/archive/2014/05/27.aspx" rel="nofollow noreferrer" title="Blog">here</a> to deliver the bearer token to my AuthorizeAttribute sub-class.  </p>
  
  <p>When the code within the AuthorizeHubConnection method executes the ticket delivered by the call to "secureDataFormat.Unprotect(token)" is always null.  I have confirmed the token is identical on both ends of the communication.</p>
  
  <p>Here is the override method:</p>
  
  <pre><code>public override bool AuthorizeHubConnection(AspNet.SignalR.Hubs.HubDescriptor hubDescriptor, IRequest request)
  {
       var dataProtectionProvider = new DpapiDataProtectionProvider();
  
       var secureDataFormat = new TicketDataFormat(dataProtectionProvider.Create());
       var token = request.QueryString.Get("Bearer");
       var ticket = secureDataFormat.Unprotect(token);
  
       if (ticket != null &amp;&amp; ticket.Identity != null &amp;&amp; ticket.Identity.IsAuthenticated)
       {
         // set the authenticated user principal into environment so that it can be used in the future
         request.Environment["server.User"] = new ClaimsPrincipal(ticket.Identity);
         return true;
        }
  
        return false;
   }
  </code></pre>
  
  <p>When I run hub without the authorize attribute and set a breakpoint within the "OnConnected" override, the Context.User property is also null.</p>
  
  <p>Any assistance would be greatly appreciated.</p>
  
  <p>Rich</p>