Last active
December 20, 2017 12:12
-
-
Save stephengardner/f39c24e99f26cfa5a753bab6cd146442 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ JwtModule } from '@auth0/angular-jwt'; | |
import { HttpClientModule } from '@angular/common/http'; | |
// Create a Factory for our JwtModule config since Angular doesn't allow functions in decorators. | |
// Also, we have to add the export keyword, otherwise Angular complains again | |
export function JwtModuleConfigFactory() { | |
return localStorage.getItem('access_token'); | |
} | |
@NgModule({ | |
bootstrap: [AppComponent], | |
imports: [ | |
// ... | |
HttpClientModule, | |
JwtModule.forRoot({ | |
config: { | |
tokenGetter: JwtModuleConfigFactory, // good to go! | |
whitelistedDomains: ['localhost:3001'] // this is just an example... | |
} | |
}) | |
] | |
}) | |
export class AppModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment