# Keycloak SSO Login in Angular

**URL:** <https://forum.keycloak.org/t/keycloak-sso-login-in-angular/29252>\
**Category:** Getting advice\
**Tags:** authentication\
**Created:** [December 17, 2024, 11:02am UTC](https://forum.keycloak.org/t/keycloak-sso-login-in-angular/29252 "2024-12-17T11:02:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prifulnath](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/prifulnath/32/10323_2.png) [@prifulnath](https://forum.keycloak.org/u/prifulnath)\
**Post date:** [December 17, 2024, 11:02am UTC](https://forum.keycloak.org/t/keycloak-sso-login-in-angular/29252/1 "2024-12-17T11:02:08Z")

</div>

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,

```typescript
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.

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/4/4aa570e2ed7d9b5b3c6051ca4613f6f34a3a8833.png)

And my keycloak configuration is as following,

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/e/ed6a682319b44233c5345f5ec905b1e088f65e81.png)

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.

---

<div class="post-metadata">

**Author:** ![embesozzi](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/embesozzi/32/12390_2.png) [@embesozzi](https://forum.keycloak.org/u/embesozzi)\
**Post date:** [December 17, 2024, 1:19pm UTC](https://forum.keycloak.org/t/keycloak-sso-login-in-angular/29252/2 "2024-12-17T13:19:13Z")

</div>

Could be related to [3rd parties cookie with Keycloak - #2 by deanmaster](https://forum.keycloak.org/t/3rd-parties-cookie-with-keycloak/28543/2).

---

<div class="post-metadata">

**Author:** ![prifulnath](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/prifulnath/32/10323_2.png) [@prifulnath](https://forum.keycloak.org/u/prifulnath)\
**Post date:** [January 9, 2025, 7:35am UTC](https://forum.keycloak.org/t/keycloak-sso-login-in-angular/29252/3 "2025-01-09T07:35:36Z")

</div>

I just tried with a local setup. `http://telemed.local/app1/web` as my web URL and `https://localhost:8181/auth` as my keycloak. And it is working as expected. I am so confused now.
