Search code examples
javascriptangularkeycloakidp

Keycloak-js client forward custom param


I am using the keycloak-js library in an Angular project and needs to forward the acr_values param when logging in, so that my idp knows which login method to use.

The forwarding inside keycloak is working, but I don't know how to forward the param from the login function.


Solution

  • The solution was to add the following snippet in keycloak.js under kc.createLoginUrl

    if (options && options.acr_values) {
       url += '&acr_values=' + encodeURIComponent(options.acr_values);
    }
    

    Then it can be used as

    keycloak.login({
       redirectUrl: XXXX,
       acr_values: XXXX
    })