python-keycloak icon indicating copy to clipboard operation
python-keycloak copied to clipboard

Getting data using client token

Open rodolfoap opened this issue 5 years ago • 1 comments
trafficstars

The USAGE seems to recommend getting user roles from a client application as this:

client_id=keycloak_admin.get_client_id("my-client")
keycloak_admin.get_client_roles_of_user(user_id="user_id", client_id=client_id)

Nevertheless, I need to connect as a client application using the client app access token, not as a user, in order to do something like this:

...
token=keycloak_openid.token(grant_type="client_credentials") # This works fine
client_id=SOMETHING.get_client_id(token, "my-client")
SOMETHING.get_client_roles_of_user(token, user_id="user_id", client_id=client_id)

How can this be done? TIA!

rodolfoap avatar Aug 21 '20 09:08 rodolfoap

The client has a built-in user "service-account-my-client" which is used for the assigned roles. But when logging in, no user session is started (see keycloak documentation). You might get the roles from the token. What's you use case?

double-a avatar May 13 '21 16:05 double-a