Skip to main content

snippets_py

Integration

New integration from credential
keycloak_admin_client = yepcode.integration.keycloak("credential-slug")
New integration from plain authentication data (username and password)
from keycloak import KeycloakAdmin
from keycloak import KeycloakOpenIDConnection

keycloak_connection = KeycloakOpenIDConnection(
server_url='baseUrl',
realm_name='realm-name',
client_id='keycloak-client-id',
username='username',
password='password',
verify=True)

keycloak_admin_client = KeycloakAdmin(connection=keycloak_connection);
New integration from plain authentication data (client secret)

from keycloak import KeycloakAdmin
from keycloak import KeycloakOpenIDConnection

keycloak_connection = KeycloakOpenIDConnection(
server_url='baseUrl',
realm_name='realm-name',
client_id='keycloak-client-id',
client_secret_key='your-client-secret',
verify=True)

keycloak_admin_client = KeycloakAdmin(connection=keycloak_connection);

Find All Realm Users

Find all realm users
users = keycloak_admin_client.get_users({})

Find a Single User

Find a single user by id
user = keycloak_admin_client.get_user('user-id')
Find a single user by email
user = keycloak_admin_client.get_users({ email: "user-email" })

Get User Roles

Get user roles
roles = keycloak_admin_client.get_client_roles_of_user(user_id='user-id')

Get User Groups

Get user groups
groups = keycloak_admin_client.get_user_groups(user_id='user-id')

Find All Realm Groups

Find all realm groups
groups = keycloak_admin_client.get_groups()

Find a Single Group

Find a single group
group = keycloak_admin_client.get_group(group_id='group-id')