Hello,
In my app I use IdentityServer4 for my web API. Now I want to use SignalR but I always get error 401. With my other http.get <T> calls I have no problems.
- [Authorize(AuthenticationSchemes = IdentityServerAuthenticationDefaults.AuthenticationScheme)]
- public class ChatHub : Hub
In the Angular Service I initialize the hub as follows.
- const tokenValue = '?token=' + this.authService.accessToken;
- const hubUrl = `${this.configurations.baseUrl + '/hubs/chat?'}looney${tokenValue}`;
-
- this.hubConnection = new signalR.HubConnectionBuilder().withUrl(hubUrl).configureLogging(signalR.LogLevel.Information).build();
For the other http.get I set the request headers as follows:
- protected get requestHeaders(): { headers: HttpHeaders | { [header: string]: string | string[]; } } {
- const headers = new HttpHeaders({
- Authorization: 'Bearer ' + this.authService.accessToken,
- 'Content-Type': 'application/json',
- Accept: 'application/json, text/plain, */*'
- });
-
- return { headers };
- }
Can someone help me here??
Thanks in advance for any advice or tip