title: SignalR + Angular: how to add Bearer token to Http Headers
body: <p>I made an asp.net core 2.0 SignalR Hub which uses Bearer Token for Authentication. Now I'm a bit lost on how to connect to it via the SignalR Angular 5 client. I actually can connect if I remove authorization from the Hub, so the connection is working, now I believe I just need to add the Authorization Bearer to the Http Headers of the connection.</p>
  
  <p>The SignalR client reference in the <code>package.json</code> file of my Angular 5 project: <code>"@aspnet/signalr-client": "^1.0.0-alpha2-final"</code></p>
  
  <p>My Angular component:</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { finalize } from 'rxjs/operators';
  import { HttpClient, HttpHeaders } from '@angular/common/http';
  import { ToastrService } from 'ngx-toastr';
  import { AuthenticationService } from '../core/authentication/authentication.service';
  import { HubConnection } from '@aspnet/signalr-client';
  
  @Component({
    selector: 'app-home',
    templateUrl: './home.component.html',
    styleUrls: ['./home.component.scss']
  })
  export class HomeComponent implements OnInit {
  
    quote: string;
    isLoading: boolean;
    jwtToken:string;
    private hubConnection: HubConnection;
  
    constructor(
      private _http: HttpClient, 
      private _auth : AuthenticationService,
      private _toastr: ToastrService) { }
  
    ngOnInit() {
      this.isLoading = false;
      this.jwtToken = this._auth.currentToken;
  
      this.hubConnection = new HubConnection('http://localhost:27081/hub/notification/');
      this.hubConnection
        .start()
        .then(() =&gt; console.log('Connection started!'))
       .catch(err =&gt; console.error('Error while establishing connection :(', err));        
      this.hubConnection.on("send", data =&gt; {
          console.log(data);
      });
    }
  
    showToastr(){
      this._toastr.success('Hello world!', 'Toastr fun!');
    }
  
  }
  </code></pre>
  
  <p>Due to reading similar questions I tried: <code>this.hubConnection.Headers.Add("token", tokenValue);</code> but it doesn't work, the Headers property doesn't exist.</p>
  
  <p>How can I add the Bearer token to the Http Headers of the HubConnection?</p>
  
  <p>Thanks for any help</p>