Looking to create an authentication module for an Angular application using Okta as the identity provider and implementing the angular-oauth2-oidc
flow. Following a guide here: . However, encountering errors when running the web app. How can I troubleshoot this issue?
auth.module.ts
@NgModule({
declarations: [
RegisterFormComponent,
SignInFormComponent,
SignInPage,
],
imports: [
CommonModule,
RouterModule.forChild(AUTH_ROUTES),
HttpClientModule,
OAuthModule.forRoot(),
],
providers: [
AuthNgOauth2OidcService,
]
})
export class AuthModule {
}
auth-ng-oauth2-oidc.service.ts
export class AuthNgOauth2OidcService implements AuthService {
authConfig: AuthConfig = {
// Identity Provider URL
issuer: environment.authIssuer,
// Redirect URL after login
redirectUri: environment.authRedirectUri,
// Client ID registered with the auth-server
clientId: environment.authClientId,
// Define scope for client permissions
// Request offline_access for refresh token
scope: 'openid profile email offline_access',
};
public constructor(
private authService: OAuthService,
) {
this.authService.configure(this.authConfig);
this.authService.tokenValidationHandler = new JwksValidationHandler();
this.authService.loadDiscoveryDocumentAndTryLogin().then();
}
}
package.json
"dependencies": {
"@angular/animations": "~8.0.1",
"@angular/cdk": "^8.2.3",
"@angular/common": "~8.0.1",
"@angular/compiler": "~8.0.1",
"@angular/core": "~8.0.1",
"@angular/forms": "~8.0.1",
"@angular/http": "~8.0.0-beta.10",
"@angular/material": "^8.2.3",
"@angular/platform-browser": "~8.0.1",
"@angular/platform-browser-dynamic": "~8.0.1",
"@angular/router": "~8.0.1",
"@fortawesome/angular-fontawesome": "^0.5.0",
"@fortawesome/fontawesome-svg-core": "^1.2.25",
"@fortawesome/free-solid-svg-icons": "^5.11.2",
"@ngrx/effects": "^8.5.2",
"@ngrx/store": "^8.4.0",
"angular-auth-oidc-client": "^10.0.10",
"angular-oauth2-oidc": "^8.0.4",
"core-js": "^2.5.4",
"mathjs": "^6.2.3",
"nativescript-angular": "~8.0.1",
"ng-oidc-client": "^1.0.7",
"oidc-client": "^1.10.0",
"reflect-metadata": "~0.1.12",
"rxjs": "~6.5.0",
"tns-core-modules": "~6.0.0",
"zone.js": "~0.9.1"
},
Error Message:
angular-oauth2-oidc.js:1346 error loading discovery document TypeError: this.interceptor.intercept is not a function
at HttpInterceptorHandler.push../node_modules/@angular/common/fesm5/http.js.HttpInterceptorHandler.handle (http.js:1228)
...
core.js:5847 ERROR Error: Uncaught (in promise): TypeError: this.interceptor.intercept is not a function
TypeError: this.interceptor.intercept is not a function
at HttpInterceptorHandler.push../node_modules/@angular/common/fesm5/http.js.HttpInterceptorHandler.handle (http.js:1228)
...