How am I supposed to use services in token getter. It was possible in previous version of this module but this newer version does not allow to do that. If we are allowed to provide config option as provider then this is doable. I was expecting to do following so that I could utilize services to provide token.
export function jwtOptionsProvider(store) {
return {
tokenGetter() {
let token;
store.select('authToken').select(1).subscribe(t => token = t);
return token;
};
}
}
[
{
provide: JWT_OPTIONS,
useFactory: jwtOptionsProvider,
deps: [Store]
}
]
Angular v 4.3.1
auth0/angular-jwt v^1.0.0-beta.5
The tokenGetter is currently set up to handle a returned string value synchronously, however, support for async token fetching is coming 馃憤
I see this was fixed in beta.6 by exporting JWT_OPTIONS token, although forRoot requires to provide dummy tokenGetter before it will be overridden with JWT_OPTIONS provider. Not very convenient. forRoot should likely be made optional, so it would be possible to configure a module with
imports: [JwtModule],
providers: [{ provide: JWT_OPTIONS, useFactory: ... }]
too.
What do you think, @chenkie ?
It might go that way. We also need to handle async token getters in the interceptor so it's not quite there yet.
Fixed in 1.0.0-beta.8. The readme has details.
@chenkie There's still a type problem, config property is required even when jwtOptionsProvider is specified.
Just merged a PR to fix and published 1.0.0-beta.9
@chenkie Great, just in time, thanks for the notification.
Most helpful comment
The
tokenGetteris currently set up to handle a returned string value synchronously, however, support for async token fetching is coming 馃憤