Skip to content

Instantly share code, notes, and snippets.

@mahizsas
Last active August 29, 2015 14:14
Show Gist options
  • Save mahizsas/5833dd100607eb0a4ccc to your computer and use it in GitHub Desktop.
Save mahizsas/5833dd100607eb0a4ccc to your computer and use it in GitHub Desktop.
var authData = storageService.get('authData');
var accessToken = authData.token;
var connection = $.hubConnection(host);
connection.qs = { 'access_token': accessToken };
var proxy = connection.createHubProxy(hub);
//This solution is based on the code of this tutorial https://github.com/louislewis2/AngularJSAuthentication
using Microsoft.AspNet.SignalR;
namespace Solution.Web.Providers
{
public class QueryStringIdProvider : IUserIdProvider
{
public string GetUserId(IRequest request)
{
var token = request.QueryString.Get("access_token");
var authenticationTicket = Startup.OAuthOptions.AccessTokenFormat.Unprotect(token);
if (authenticationTicket == null || authenticationTicket.Identity == null ||
!authenticationTicket.Identity.IsAuthenticated)
return string.Empty;
var userId = authenticationTicket.Identity.Name;
return userId;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment