Keycloak Angular Cannot read property 'resourceAccess' of undefined

Viewed 1197

i want to trying few rule with keycloak auth. i need 2 route, someone "newsite" other "list"

We creating a site as free. But you cant see list of sites without auth. But given this error:

ERROR Error: Uncaught (in promise): An error happened during access validation. Details:TypeError: Cannot read property 'resourceAccess' of undefined
    at resolvePromise (zone-evergreen.js:793)
    at resolvePromise (zone-evergreen.js:752)
    at zone-evergreen.js:854
    at ZoneDelegate.invokeTask (zone-evergreen.js:400)
    at Object.onInvokeTask (core.js:41249)
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at Zone.runTask (zone-evergreen.js:168)
    at drainMicroTaskQueue (zone-evergreen.js:570)

How can I fix this issue/problem ?

My code samples here(only relevant to this):

  {path: 'newsite',component: NewsiteComponent},
  {path:'list',component:ExamplelistComponent,canActivate: [AppAuthGuard]},


 providers: [{
  provide: KeycloakService,
  useValue: keycloakService
}],


export class AppModule implements DoBootstrap {
async ngDoBootstrap(appRef: ApplicationRef) {
try {
  await keycloakService.init({ config: environment.keycloak });
  appRef.bootstrap(AppComponent);
} catch (error) {
  console.error("Keycloak init failed", error);
}

} }

Versions:

keycloak-angular npm: "^7.2.0",

Keycloak server : docker keycloak:9.0.0

Angular 8

Helper blogs/pages:

https://medium.com/@sairamkrish/keycloak-integration-part-2-integration-with-angular-frontend-f2716c696a28

https://github.com/mauriciovigolo/keycloak-angular/tree/angular7-keycloak3/examples/keycloak-heroes/src/app

1 Answers
Related