public string GenerateClientAccessToken(string hubName, string userId = null, IList <Claim> claims = null, TimeSpan?lifeTime = null) { var claimsWithUserId = new List <Claim>(); if (userId != null) { claimsWithUserId.Add(new Claim(ClaimTypes.NameIdentifier, userId)); } ; if (claims != null) { claimsWithUserId.AddRange(claims); } return(_endpointProvider.GenerateClientAccessTokenAsync(hubName, claimsWithUserId, lifeTime).Result); }
private async Task GenerateClientAccessTokenAsync( IServiceEndpointProvider provider, HostContext context, string url, IEnumerable <Claim> claims) { try { var accessToken = await provider.GenerateClientAccessTokenAsync(null, claims); await SendJsonResponse(context, GetRedirectNegotiateResponse(url, accessToken)); } catch (AzureSignalRAccessTokenTooLongException ex) { Log.NegotiateFailed(_logger, ex.Message); context.Response.StatusCode = 413; await context.Response.End(ex.Message); } }
public string GenerateClientAccessToken(string hubName, string userId = null, IList <Claim> claims = null, TimeSpan?lifeTime = null) { if (_endpointProvider == null) { throw new InvalidOperationException(EmptyConnectionStringMessage); } var claimsWithUserId = new List <Claim>(); if (userId != null) { claimsWithUserId.Add(new Claim(ClaimTypes.NameIdentifier, userId)); } ; if (claims != null) { claimsWithUserId.AddRange(claims); } return(_endpointProvider.GenerateClientAccessTokenAsync(hubName, claimsWithUserId, lifeTime).Result); }