angular2-jwt: No JWT present or has expired after upgrading to Angular4

Hi, I am getting this error after updating from Angular 2 to 4 and I am using the latest angular2-jwt

AuthHttpError {__zone_symbol__error: Error: No JWT present or has expired
    at AuthHttpError.ZoneAwareError (http://localhost:3000/poly……}

I found this issue but even if I comment out the getter function I still get this error.

export function AuthFactory(http: Http, options: RequestOptions) {
    return new AuthHttp(new AuthConfig({
        // tokenName: 'id_token',
        // tokenGetter: (() => localStorage.getItem('id_token')),
        globalHeaders: [{ 'Content-Type': 'application/json' }],
    }), http, options);
};

Any idea why I am getting this error?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

Thanks! For everyone else getting this error:

angular2-jwt 0.1.28 + Angular 2.x = working angular2-jwt 0.1.28 + Angular 4.x = working angular2-jwt 0.2.0 + Angular 4.x = working angular2-jwt 0.2.1 + Angular 4.x = not working angular2-jwt 0.2.2 + Angular 4.x = not working angular2-jwt 0.2.3 + Angular 4.x = not working

How do you fix this issue?

Confirmed that angular2-jwt 0.2.0 works with Angular 4.x

Ran into the same issue. However, even with 0.2.0 I cannot get it to work again. When setting noClientCheck to true in the config, it works.

export function authHttpServiceFactory(http: Http, options: RequestOptions) {
  return new AuthHttp(new AuthConfig({
    noClientCheck: true
  }), http, options)
}