Keycloak
Keycloak allows you to manage user authentication and authorization in your apps. This integration provides a client for keycloak admin API
- JavaScript
- Python
Network Connection needs
This integration needs network access to the server where the service is running.
See the Network access page for details about how to achieve that.
Credential configuration
To configure this credential, you need the URL
of the server and the realmName
.
Optionally, you can set axios request config
in the JSON field, which will be sent in all requests.
To authenticate, you need the client ID
and then you need username
and password
for the password grant type,
or client secret
for the client_credentials grant type.
In the second JSON field, you can set the extra config you can find in the examples here.
Here is an example of a filled credential configuration form in YepCode:
Keycloak Snippets available in Editor
The title is the triggering text for YepCode to autocomplete the script.
- JavaScript
- Python
Integration
const keycloakAdminClient = await yepcode.integration.keycloak("credential-slug");
const KeycloakAdminClient = require("@keycloak/keycloak-admin-client").default;
const keycloakAdminClient = new KeycloakAdminClient({
baseUrl: "baseUrl",
realmName: "realm-name"
});
await keycloakAdminClient.auth({
grantType: "password",
clientId: "keycloak-client-id",
username: "username",
password: "password"
});
const KeycloakAdminClient = require("@keycloak/keycloak-admin-client").default;
const keycloakAdminClient = new KeycloakAdminClient({
baseUrl: "baseUrl",
realmName: "realm-name"
});
await keycloakAdminClient.auth({
grantType: "client_credentials",
clientId: "keycloak-client-id",
clientSecret: "your-client-secret"
});
Change Realm to Manage
keycloakAdminClient.setConfig({
realmName: "realm-name"
});
Find All Realm Users
const users = await keycloakAdminClient.users.find();
Find a Single User
const user = await keycloakAdminClient.users.findOne({ id: "user-id" });
const user = await keycloakAdminClient.users.findOne({ email: "user-email" });
Get User Roles
const roles = await keycloakAdminClient.users.listRoleMappings({ id: "user-id" });
Get User Groups
const groups = await keycloakAdminClient.users.listGroups({ id: "user-id" });
Find All Realm Groups
const groups = await keycloakAdminClient.groups.find();
Find a Single Group
const group = await keycloakAdminClient.groups.findOne({ id: "group-id" });
Integration
keycloak_admin_client = yepcode.integration.keycloak("credential-slug")
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);
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
users = keycloak_admin_client.get_users({})
Find a Single User
user = keycloak_admin_client.get_user('user-id')
user = keycloak_admin_client.get_users({ email: "user-email" })
Get User Roles
roles = keycloak_admin_client.get_client_roles_of_user(user_id='user-id')
Get User Groups
groups = keycloak_admin_client.get_user_groups(user_id='user-id')
Find All Realm Groups
groups = keycloak_admin_client.get_groups()
Find a Single Group
group = keycloak_admin_client.get_group(group_id='group-id')