Using Key Cloak created groups and assigned roles to the groups. Than created the users and assigned the users to specific groups.
To access all this in my application I am using Python-Keycloak
As mentioned in github doc, using following code to access the user information.
from keycloak import KeycloakOpenID
keycloak_openid = KeycloakOpenID(server_url="http://localhost:8080/auth/",
client_id="account",
realm_name="demo",
client_secret_key="my_secret_key")
config_well_know = keycloak_openid.well_know()
token = keycloak_openid.token("username", "password")
userinfo = keycloak_openid.userinfo(token['access_token'])
Getting following userinfo
{
'family_name': 'Lastname',
'preferred_username': 'user_name',
'sub': 'some_key',
'given_name': 'Fistname',
'name': 'Firstname Lastname',
'email': 'email@example.com'
}
How can I access the group and roles information of the user.