question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configuration with factory doesn't work

See original GitHub issue

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
            }
        }),

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Sambegocommented, May 15, 2020

The documentation has been updated to be clearer about configuring the options with a jwtOptionsFactory.

1reaction
davidquintardcommented, Apr 15, 2020

Thank you very much @Sambego , you saved my life!!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reset your Android device to factory settings - Google Support
Open your phone's Settings app. Tap Accounts. If you don't have the option to tap "Accounts," get help from your device manufacturer. You'll...
Read more >
Solved: Reset to factory default doesn't work on 1142 AP
We want to reset to factory defaults because we want to delete the configuration and force the AP to get a new config...
Read more >
Unable to factory default my srx240 firewall | SRX
Hi guys, need help on this as i was unable to reset my firewall to factory default either from reset button or command...
Read more >
Where to store "factory defaults" configuration settings, so they ...
We need to store the factory defaults in a file that is included in the executable, or distributed with it. We can write...
Read more >
How To Factory Reset Any Windows 10 Computer - YouTube
If they don't work, comment with your exact model and we can help find the correct F Key. Q: What if the factory...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found