Keycloak-angular: Lack of id in KeycloakProfile object

Created on 12 Mar 2018  路  15Comments  路  Source: mauriciovigolo/keycloak-angular

Hello, first of all - your library is really great, thanks for your effort :)
To the point though:
I'm invoking loadUserProfile() so I can process KeycloakProfile but the result doesn't have id set - it's undefined all the time for me. All the other fields like email, firstname, lastname and even additional attributes set on my keycloak server are found - the only missing is id. By id I mean id set by keycloak itself eg: fb069cbd-689c-4108-8a0b-e03196eea53f. Do you know how can I get that id filled in KeycloakProfile returned from loadUserProfile()?

Question

Most helpful comment

Hi, I can reproduce the issue using:

  • keycloak-angular: 5.1.0
  • Keycloak server: 3.4.0.Final
  • @angular/core: 7.2.9

Request to: http://localhost:8080/auth/realms/tenant1/account
Response: {"username":"jdoe","firstName":"John","lastName":"Doe","email":"[email protected]","emailVerified":false,"attributes":{}}

All 15 comments

Hi @michalc94,

I just tried in my keycloak sandbox environment and the KeycloakProfile.id property was successfully loaded / returned. So I suggest you to take a look at your browser developer tools and check if the http response to the account app returned the client id. If true this value should be loaded.

Let me know if this helps you and if the problem persists.

Hi @michalc94,

I'm closing this issue. If you face any problems related to this situation, please reopen this issue, okay?

@doublemc I've got the same problem. Keycloak /account endpoint returns no id. How have you fix that problem?

hello @doublemc, this property should exist in the response of loadProfileMethod. Could you give me more details about it? Like keycloak-angular, keycloak and angular versions you are using.
When I answered @doublemc I tried with keycloak-heroes example. You can debug or print the result in your console. Thanks!

Hi, I can reproduce the issue using:

  • keycloak-angular: 5.1.0
  • Keycloak server: 3.4.0.Final
  • @angular/core: 7.2.9

Request to: http://localhost:8080/auth/realms/tenant1/account
Response: {"username":"jdoe","firstName":"John","lastName":"Doe","email":"[email protected]","emailVerified":false,"attributes":{}}

Hi,
same issue here.

Versions:

  • keycloak-angular: 7.0.1
  • keycloak-server: 4.7 Final
  • Angular: 7.2.5

Have the same problem - receive as result of loadUserProfile():
{username: "dixx", emailVerified: false, attributes: {}}
Version: keycloak-angular: 6.1.0
So evidently is the problem independent from the software version.

I tested it with this version and got the same problem :

  • Keycloak-angular: 7.0.1
  • Angular: 7.2.15
    I can got the user id !

@guendouzbachir Which version of keycloak-js are you including?

@guendouzbachir Which version of keycloak-js are you including?

The lastest : [email protected]

@guendouzbachir I am seeing the identifier show up as expected in my setup with the same version of Keycloak. In the type definition of KeycloakProfile it's possible id is not present so this seems to be expected behaviour.

Since this object is returned by Keycloak's JavaScript adapter and not by Keycloak Angular this is not a bug in Keycloak Angular. If you have questions on this behaviour I would suggest you create an issue on Keycloak's issue tracker or start a thread on the mailing list or forums.

I tried with Public client it work perfectly
But when i switch to confidential client with this configuration it didn't work for me :
keycloakConfig :{
url: 'http://localhost:8080/auth',
realm: 'master',
clientId: 'clientConfidential',
credentials : {
secret : '3fb5b2cd-2260-4479-baa9-32d7258f2108'
}
}
Did any one test the this library with confidential client ?

Having this issue as well

With th following packages, I cannot get and Id value in KeycloakProfile.
"@angular/compiler": "~9.1.12",
"keycloak-angular": "^8.0.1",
"keycloak-js": "^11.0.3"

Any fix ?

Returned to this situation after 2 years and can confirm that still persists with same version @dogutumerdem mentions.
However, managed to retrieve user's id by using:

this.keycloakService.getKeycloakInstance().subject

Not happiest nor intuitive solution, but probably can be used until KeycloakProfile is updated.

Was this page helpful?
0 / 5 - 0 ratings