sendAccessToken is sending null token when using local storage
here is my configuration
import { AuthConfig } from 'angular-oauth2-oidc';
export const authConfig: AuthConfig = {
issuer: '',
redirectUri: window.location.origin + '/home',
silentRefreshRedirectUri: window.location.origin + '/assets/silent-refresh.html',
clientId: '',
dummyClientSecret: '',
scope: '',
strictDiscoveryDocumentValidation: false,
oidc: false
}
private configureWithNewConfigApi() {
this.oauthService.configure(authConfig);
this.oauthService.setStorage(localStorage);
this.oauthService.tokenValidationHandler = new JwksValidationHandler();
this.oauthService.loadDiscoveryDocument('').then(() => {
this.oauthService.tryLogin();
this.oauthService.setupAutomaticSilentRefresh();
});
}
md5-1e1ffcd102308d6ad3e689fff3c8ca9b
OAuthModule.forRoot({
resourceServer: {
allowedUrls: [''],
sendAccessToken: true
}
})
when I remove this.oauthService.setStorage(localStorage) it is working fine as expected
can you please look into this issue asap
I have this issue too, whilst debugging the issue, looks like when angular-oauth2-oidc configures the DefaultOAuthInterceptor it uses 'sessionStorage', ignoring the set storage 'localStorage', a work around is to register an interceptor manually
You could also (as a workaround) do this in you app module
...
providers: [
...
{ provide: OAuthStorage, useValue: localStorage },
...
]
....
Thanks for this hint. I would consider this the official solution. setStorage is there only for legacy reasons to prevent breaking existing code. But using DI is the way to go.
You could also (as a workaround) do this in you app module
... providers: [ ... { provide: OAuthStorage, useValue: localStorage }, ... ] ....
You saved my day, thanks.
Most helpful comment
You could also (as a workaround) do this in you app module