Angular-oauth2-oidc - Can't get it to use localStorage for tokens

199 views Asked by At

I am trying to follow the example from this page https://manfredsteyer.github.io/angular-oauth2-oidc/docs/additional-documentation/configure-custom-oauthstorage.html

What I am trying to do is to use localStorage for storing the tokens .

I have followed the article and declared the factory method like this

export function storageFactory() : OAuthStorage {
  console.log('calling factory method');
  return localStorage;
}

And add it in my providers in app.module like this:

@NgModule({
  imports: [ 
    // etc.
    HttpClientModule,
    OAuthModule.forRoot()
  ],
  declarations: [
    AppComponent,
    HomeComponent,
    // etc.
  ],
  bootstrap: [
    AppComponent 
  ],
  providers: [
    { provide: OAuthStorage, useFactory: storageFactory }
  ]
})
export class AppModule {
}

However it still saves tokens into session storage . Also the console.log in my factory method is never displayed and I suspect my factory method is ignored I am using angular14 and version 14 of project. Any ideas what am I missing?

0

There are 0 answers