Description
I'm trying to use jwtOptionsFactory to handle getting token from ngrx store.
The interceptor works just fine, but when I try to us JwtHelperService without passing token (I guess it uses tokengetter by default) or with passing token via this.jwtHelperService.tokenGetter() does not work because my factory return promise while the method from service tries run split method on promise, not on string...
My code:
function jwtOptionsFactory(store: Store<any>): object {
return {
whitelistedDomains: ['localhost:5500'],
tokenGetter: () => {
return store.select(FromAppState.selectAuthToken)
.pipe(take(1))
.toPromise();
}
};
}
@NgModule({
// ...
imports: [
// ...
JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [Store]
}
}),
// ...
]
bootstrap: [AppComponent]
})
export class AppModule {}
constructor(private dialogService: DialogService,
private jwtHelperService: JwtHelperService) { }
ngOnInit(): void {
console.log(this.jwtHelperService.tokenGetter()); // <= return promise, not string
console.log(this.jwtHelperService.decodeToken(this.jwtHelperService.tokenGetter()));
console.log(this.jwtHelperService.isTokenExpired(this.jwtHelperService.tokenGetter()));
console.log(this.jwtHelperService.getTokenExpirationDate(this.jwtHelperService.tokenGetter()));
}
error:

Please fix this
Also it would be great if this would also supports Observable
Prerequisites
Environment
Please provide the following:
- Version of angular2-jwt being used: "@auth0/angular-jwt": "^2.1.0",
- Version of the platform or framework used, if applicable: "@angular/core": "~8.0.0"
Description
I'm trying to use jwtOptionsFactory to handle getting token from ngrx store.
The interceptor works just fine, but when I try to us
JwtHelperServicewithout passing token (I guess it uses tokengetter by default) or with passing token viathis.jwtHelperService.tokenGetter()does not work because my factory return promise while the method from service tries runsplitmethod on promise, not on string...My code:
error:

Please fix this
Also it would be great if this would also supports Observable
Prerequisites
/issues) and [PRs](https://github.com/auth0/angular2-jwt
/pulls).
Environment
Please provide the following: