Reputation: 567
I am trying to check the keycloak is logged in or not when a user take my website. But the execution end unexpectedly.
In order to check that user is already logged in or not, I am using the following code in my angular project,
var keycloak = new Keycloak({
url: environment.kc_url,
realm: environment.kc_realm,
clientId: environment.kc_client_id,
});
await keycloak
.init({
onLoad: 'check-sso',
redirectUri: "http://localhost:4200/home?loginType=provider"
});
const tokenDetails = {
access_token: keycloak.token,
refresh_token: keycloak.refreshToken,
refresh_token_exp: keycloak?.refreshTokenParsed?.exp,
};
console.log('Keycloak initialized successfully:', tokenDetails);
Code execution reach till init statement and the execution stop after that. When I check the network calls, I can see the API call for the init and it return 204 as expected. All the information in the init call is correct as well.
And my keycloak configuration is as following,
Tried adding then
catch
statements. But still code ends without entering in the code block of then
or catch
. Tried testing with a sample react project as well. It also give me the same error.
If I am using login-required
instead of check-sso
it is working.
Can anyone have any idea what am I doing wrong here? Felt like a simple solution, but still not able debug.
Upvotes: 0
Views: 60