Closed falconsapsan closed 10 months ago
My mistake was that I had also included the KeycloakAngularModule in the import section of the AppComponent. With that configuration, everything is working.
providers: [
provideHttpClient(
withInterceptors([
authInterceptor,
]),
withInterceptorsFromDi()
),
KeycloakAngularModule,
importProvidersFrom(KeycloakAngularModule),
KeycloakBearerInterceptor,
{
provide: HTTP_INTERCEPTORS,
useClass: KeycloakBearerInterceptor,
multi: true,
},
{
provide: APP_INITIALIZER,
useFactory: initializeKeycloak,
multi: true,
deps: [KeycloakService]
},
provideRouter(routes),
],
};```
Versions.
keycloak-angular: 15.0.0 keycloak-js: 23.0.3 keycloak: 23.0.0 angular: 17.0.7
Repro steps.
app.config.ts
main.ts
start.component.ts
auth.guard.ts
The log given by the failure.
I have a component named start.component.ts in which I want to get the authentication status and the profile of the authenticated user." In this component, isLoggedIn is always false, and getKeycloakInstance is always undefined.
The AuthGuard, meanwhile, works correctly; inside it, there's always getKeycloakInstance() available, and it's possible to get the user's profile. Please suggest ways to solve this problem.