Open MohamadTahir opened 1 year ago
i have same problem. please send me solution if you ressolve it.
options.Events = new JwtBearerEvents
{
OnMessageReceived = context =>
{
var accessToken = context.Request.Query["access_token"];
var path = context.HttpContext.Request.Path;
if (!string.IsNullOrEmpty(accessToken) && path.StartsWithSegments("/hubs"))
{
context.Token = accessToken;
}
return Task.CompletedTask;
}
};
Add jwt bearer event and map the access_token
gotten from query to context, since Authorize attribute of signalr does not get data from http request like in a controller.
my dontet project has a hub that requires users to have a valid jwt token, my configuration is
but I am getting the following error.
I am sure the connection is failing because of the Authorize Attribute, removing the attribute from the hub solves the problem, but I need the authorize tag.