Skip to content

Instantly share code, notes, and snippets.

@yonzin
Last active August 30, 2019 13:54
Show Gist options
  • Save yonzin/7bc7770f24b0475e5668d2e852d584d0 to your computer and use it in GitHub Desktop.
Save yonzin/7bc7770f24b0475e5668d2e852d584d0 to your computer and use it in GitHub Desktop.
auth0/angular2-jwt ionic and capacitor storage configuration
import { JwtModule, JWT_OPTIONS } from '@auth0/angular-jwt';
import { Plugins } from '@capacitor/core';
// ...
export function jwtOptionsFactory() {
return {
tokenGetter: () => {
return Plugins.Storage.get({ key: 'jwt_token' }).then(storedData => storedData.value);
},
whitelistedDomains: environment.whitelistedDomains,
blacklistedRoutes: environment.blacklistedRoutes,
};
}
// ...
@NgModule({
// ...
imports: [
JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: []
}
})
]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment