Skip to content

NgxJwtModule

Richard edited this page Jan 6, 2018 · 1 revision

Description

The NgxJwtModule is an Angular module that contains the JwtInterceptor for intercepting HTTP requests and adding an Authorization header field to the request with a JWT token in the field value.

The module should be imported to the application's root module like so:

imports: [
  NgxJwtModule.forRoot({
    config: {
      tokenGetter: createTokenGetter(),
      whitelistedDomains: [],
      blacklistedDomains: ['auth-server.com'],
      throwNoTokenError: true,
      skipWhenExpired: false,
      headerName: 'Authorization',
      authScheme: 'Bearer'
    }
  })
]

The JwtInterceptor will call tokenGetter() to determine the token to be inserted into the header field's value.

Clone this wiki locally