Hi,
We are trying to integrate the keycloak-js lib in to your react web app. Depending on what
page you log in through we want to use different clientIds.
The problem is that each time we render the app and create a new instance of the Keycloak
object from keycloak-js we need to supply a clientId. Before the user logs in through the
keycloak portal we can figure out what clientId should be used depending on what page the
user is coming from, but when redirected back from the keycloak login portal we can't
know. We have tried to only use the keycloak.init({ onLoad: 'login-required' })
function and just picking a random clientId for the second initiation of the object but
this does not seem to work when the user first uses one of the clientIds and then the
other after the redirect. We have also tried:
keycloak.init()
if (!keycloak.authenticated) {
keycloak.login({redirectUri: 'example.com?clientId=' + clientId})
}
So that we can use the query param of the redirect to know how to initialise the Keycloak
object with the right clientId. But here keycloak.authenticated is always false.
Is there a common solution for handling multiple clientIds? Are we using the init() and
login() combo wrong?
We are using Keycloak server version 4.3.0.Final and keycloak-js 4.4.0
Best regards
Albin
Show replies by date