I'm currently working on integrating keycloak-angular into my project, but I'm facing an issue with setting the bearer token as the default for my HTTP requests.
"keycloak-angular": "9.1.0" "keycloak-js": "16.0.0" "Angular": "13.0.2"
function initializeKeycloak(keycloak: KeycloakService) {
return async () =>
await keycloak.init({
config: {
url: 'https://127.0.0.1:8443/auth',
realm: '*****',
clientId: '****',
},
initOptions: {
onLoad: 'login-required',
checkLoginIframe: false,
},
loadUserProfileAtStartUp: true,
enableBearerInterceptor: true,
bearerExcludedUrls: [],
bearerPrefix:'Bearer '
});
}
@NgModule({
declarations: [
AppComponent,
],
imports: [
CoreModule,
BrowserModule,
KeycloakAngularModule,
AppRoutingModule
],
providers: [
{ provide: LOCALE_ID, useValue: 'it' },
{
provide: APP_INITIALIZER,
useFactory: initializeKeycloak,
multi: true,
deps: [KeycloakService]
},
],
bootstrap: [AppComponent]
})