python-keycloak
python-keycloak copied to clipboard
Getting data using client token
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!
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?