mauriciovigolo / keycloak-angular

Easy Keycloak setup for Angular applications.
MIT License
727 stars 280 forks source link

Lack of id in KeycloakProfile object #30

Closed doublemc closed 6 years ago

doublemc commented 6 years ago

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()?

mauriciovigolo commented 6 years ago

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.

mauriciovigolo commented 6 years ago

Hi @michalc94,

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

muaddib123 commented 6 years ago

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

mauriciovigolo commented 6 years ago

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!

dsnoeck commented 5 years ago

Hi, I can reproduce the issue using:

Request to: http://localhost:8080/auth/realms/tenant1/account Response: {"username":"jdoe","firstName":"John","lastName":"Doe","email":"john.doe@company.com","emailVerified":false,"attributes":{}}

dsarcevic commented 5 years ago

Hi, same issue here.

Versions:

Dampfpfeife commented 5 years ago

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.

guendouzbachir commented 4 years ago

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

jonkoops commented 4 years ago

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

guendouzbachir commented 4 years ago

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

The lastest : keycloak-js@8.0.1

jonkoops commented 4 years ago

@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.

guendouzbachir commented 4 years ago

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 ?

ahahn95 commented 4 years ago

Having this issue as well

dogutumerdem commented 3 years ago

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 ?

dsarcevic commented 3 years ago

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.

Dampfpfeife commented 3 years ago

Thanks for this workaround - works perfect. Maybe even better than the "original", as the ID is available at once and not "later" due to the promise for profile loading.