Skip to content

Configuration with factory doesn't work #645

@davidquintard

Description

@davidquintard

Hi there, i'm using "@auth0/angular-jwt": "^4.0.0",.
I followed documentation:
https://github.com/auth0/angular2-jwt#configuration-for-ionic-2

But factory doesn't work.
Doesn't work with ionic storage neither localstorage.

export function jwtOptionsFactory(storage: Storage) {
   return {
       tokenGetter: () => {
           // return storage.get('access_token');
           return localStorage.getItem('access_token');
       }
   }
}
...
JwtModule.forRoot({
           jwtOptionsProvider: {
               provide: JWT_OPTIONS,
               useFactory: jwtOptionsFactory,
               deps: [Storage]
           }
       }),

Without factory, it works fine:

export function tokenGetter() {
    return localStorage.getItem('access_token');
}
...
JwtModule.forRoot({
            config: {
                tokenGetter: tokenGetter,
                whitelistedDomains: endpoint.jwtWhitelist
            }
        }),

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions