Angular-Keycloak is not adding the bearer token by default to my http requests

Discussão em 'Angular' iniciado por Fabio, Janeiro 5, 2025.

  1. Fabio

    Fabio Guest

    I'm trying to implement keycloak-angular but I'm not able to add the bearer token by default to 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]
    })

    Continue reading...

Compartilhe esta Página