一、客户端请求SignalR时,将Token放入QueryString
var connection = new HubConnectionBuilder().WithUrl($"http://xxx/signalr?Bearer={Token}").Build();
二、在Startup中,在UseAuthentication之前获取Token并放入Header
app.Use((context, next) => { if (context.Request.Query.TryGetValue("Bearer", out var token)) context.Request.Headers.Add("Authorization", $"Bearer {token}"); return next.Invoke(); });