Skip to content

Instantly share code, notes, and snippets.

@philly-vanilly
Last active May 30, 2019 09:35
Show Gist options
  • Save philly-vanilly/5fc9c94dbb36dfa67d7ce36161016897 to your computer and use it in GitHub Desktop.
Save philly-vanilly/5fc9c94dbb36dfa67d7ce36161016897 to your computer and use it in GitHub Desktop.
// sometimes you can't use window/document/location in AOT
const origin = environment.production ? 'https://philly-vanilly.github.io/init-auth' : 'http://localhost:4200';
const configAuthZero: AuthConfig = {
issuer: 'https://philly-vanilly.auth0.com/',
customQueryParams: { audience: 'https://philly-vanilly.auth0.com/api/v2/' },
redirectUri: `${origin}/index.html`,
silentRefreshRedirectUri: `${origin}/silent-refresh.html`,
clientId: 'r4gL1ntxR2lnodnu81WFnWNOWdO5SFuV',
scope: 'openid profile email',
clearHashAfterLogin: true,
showDebugInformation: true
};
configAuthZero.logoutUrl =
`${configAuthZero.issuer}v2/logout?client_id=${configAuthZero.clientId}&returnTo=${encodeURIComponent(configAuthZero.redirectUri)}`;
@NgModule({
imports: [OAuthModule.forRoot()],
providers: [
InitialAuthService,
{ provide: AuthConfig, useValue: configAuthZero },
{
provide: APP_INITIALIZER,
useFactory: (initialAuthService: InitialAuthService) => () => initialAuthService.initAuth(),
deps: [InitialAuthService],
multi: true
},
],
})
export class AuthModule {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment