I have installed the @auth0/angular-jwt package and as in Anular2-jwt there is class called AuthHttp(which will add Bearer automatically and also set into the Authorization header as well).
How can we achieve the same thing with @auth0/angular-jwt
AuthHttp
is no more in this module but you can achieve similar behavior with @auth0/angular-jwt
. Try adding this configuration to you app module :
import { JwtModule } from '@auth0/angular-jwt';
...
export function tokenGetter() {
return localStorage.getItem('access_token');
}
@NgModule({
...
JwtModule.forRoot({
config: { tokenGetter: tokenGetter,
whitelistedDomains: ['http://localhost:8080'],
blacklistedRoutes: [],
headerName: 'x-auth-token',
throwNoTokenError: true,
skipWhenExpired: false,
authScheme:'name of auth scheme' //default is Bearer
}
})
....
})
export class AppModule { }
For more details refer here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With