I use the ng2-signalr in ionic version 2. The problem is that I do not know how to set the authorization header. I have a search but have not found any example.
My code to connect to the server.
let options: IConnectionOptions = { qs:{userId:1}, url: "http://192.168.0.211:44337"}; console.log("Stage 1"); //Header for 'this.singalR.connect' this.signalR.connect(options) .then((connection) => { console.log("Client Id: " + connection.id); }, (err) => { console.log("SignalR Error: " + JSON.stringify(err)); });
How to set below title?
var headers = new Headers({ 'Content-Type': "application/json", "Authorization": 'Bearer ' + accessToken
Library: ng2-signalr
Update 1
Here's the link for the Query String Solution . The workaround is to pass authorization token to qs and handle it accordingly. But I want to set the title so that this solution does not suit me. Another reason when I have one other client (Simple angularjs signalr) that works fine when I set the header as shown below.
$.signalR.ajaxDefaults.headers = { Authorization:
Note. Before implementing authorization, the same code works fine, since I do not need to set the authorization header.
source share