File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 1
1
using System . Text ;
2
+ using System . Threading . Tasks ;
2
3
using ChatSample . Helpers ;
3
4
using ChatSample . Hubs ;
4
5
using ChatSample . IServices ;
@@ -39,6 +40,20 @@ public void ConfigureServices (IServiceCollection services) {
39
40
ValidateIssuer = false ,
40
41
ValidateAudience = false
41
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
+ } ;
42
57
} ) ;
43
58
44
59
// configure DI for application services
You can’t perform that action at this time.
0 commit comments