We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 199c0e5 commit 47e8efeCopy full SHA for 47e8efe
ChatSample/ChatSample/Startup.cs
@@ -1,4 +1,5 @@
1
using System.Text;
2
+using System.Threading.Tasks;
3
using ChatSample.Helpers;
4
using ChatSample.Hubs;
5
using ChatSample.IServices;
@@ -39,6 +40,20 @@ public void ConfigureServices (IServiceCollection services) {
39
40
ValidateIssuer = false,
41
ValidateAudience = false
42
};
43
+ x.Events = new JwtBearerEvents {
44
+ OnMessageReceived = context => {
45
+ var accessToken = context.Request.Query["access_token"];
46
+
47
+ // If the request is for our hub...
48
+ var path = context.HttpContext.Request.Path;
49
+ if (!string.IsNullOrEmpty (accessToken) &&
50
+ (path.StartsWithSegments ("/hubs/chat"))) {
51
+ // Read the token out of the query string
52
+ context.Token = accessToken;
53
+ }
54
+ return Task.CompletedTask;
55
56
+ };
57
});
58
59
// configure DI for application services
0 commit comments