Last active
August 29, 2015 14:14
-
-
Save mahizsas/5833dd100607eb0a4ccc 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
var authData = storageService.get('authData'); | |
var accessToken = authData.token; | |
var connection = $.hubConnection(host); | |
connection.qs = { 'access_token': accessToken }; | |
var proxy = connection.createHubProxy(hub); |
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
//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