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
Please provide the following:
@spiotr12 Yes I just yesterday noticed that this was broken myself, thanks for raising the issue. I've put it into our backlog to get looked at.
I have the same problem in version 3.0. Any luck with bug fix?
Yes, it's still an issue. :(
Any luck with the fix?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇♂️
Was this fixed or just forgotten?
It hasn't been fixed but is in our backlog. We'd appreciate any help if you fancy having a go at getting this working.
+1
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇♂️
Any news on this one?
Until the PR is merged, the workaround can be installed via github package registry: "@smasala/auth0-angular-jwt": "^4.2.1",
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇♂️
Most helpful comment
Yes, it's still an issue. :(
Any luck with the fix?