keycloakprofile id is undefined

1.1k views Asked by At

I need help! I am using

"keycloak-angular": "^8.0.1",
"keycloak-js": "^11.0.2",

When I do

  async ngOnInit() {
   if (await this.keycloakService.isLoggedIn()) {
      this.userDetails = await this.keycloakService.loadUserProfile();
      console.log("user id ---> "+this.userDetails.id);
    }
  }

I get the following output

user id --->  undefined

However, When I do

this.userDetails.email

I get the email id of the user.

The back end spring security application does get the user id/principal.

Please help me with a way to get the user id please?

1

There are 1 answers

0
The g On

I got the user id from the following

this.keycloakService.getKeycloakInstance().subject