title: angular jwt invalid token
body: <p>I have this issue with angular JWT token, which works on my api from Postman but not from the angular call. Request details as follow: <a href="https://i.stack.imgur.com/L6Tsr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L6Tsr.png" alt="screen shot"></a> </p>
  
  <p>I copied the token showed in the response and generate a request through Postman which works.</p>
  
  <p>Any idea why this token could be invalid when sent from angular service? </p>
  
  <p>Postman result below:</p>
  
  <p><a href="https://i.stack.imgur.com/d5Ilq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d5Ilq.png" alt="enter image description here"></a></p>
  
  <p>here is the code that produces the token angular side></p>
  
  <pre><code>    import { Injectable } from '@angular/core';
  
      import {
        HttpRequest,
        HttpHandler,
        HttpEvent,
        HttpInterceptor} from '@angular/common/http';
      //import { AuthService } from './auth/auth.service';
      import { Observable } from 'rxjs/Observable';
      import { Http } from "@angular/http/http";
      import { AuthService } from "./auth.service";
      import { HttpClient } from "@angular/common/http";
      @Injectable()
      export class TokenInterceptor implements HttpInterceptor {
        constructor(public auth: AuthService) { }
        intercept(request: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; {
  
          request = request.clone({
            setHeaders: {
              Authorization: `Bearer ${this.auth.getToken()}`
            }
          });
          return next.handle(request);
        }
      }
  
    public getToken(): string {
      return localStorage.getItem('token');
    }
  </code></pre>