Skip to main content

Keycloak

Keycloak allows you to manage user authentication and authorization in your apps. This integration provides a client for keycloak admin API

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.

Keycloak snippets available in YepCode editor

note

The title is the triggering text for YepCode to autocomplete the script

Integration

New integration from credential
const keycloakAdminClient = await yepcode.integration.keycloak("credential-slug");
New integration from plain authentication data (username and password)
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"
});
New integration from plain authentication data (client secret)
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

Change realm
keycloakAdminClient.setConfig({
realmName: "realm-name"
});

Find all realm users

Find all realm users
const users = await keycloakAdminClient.users.find();

Find a single user

Find a single user by id
const user = await keycloakAdminClient.users.findOne({ id: "user-id" });
Find a single user by email
const user = await keycloakAdminClient.users.findOne({ email: "user-email" });

Get user roles

Get user roles
const roles = await keycloakAdminClient.users.listRoleMappings({ id: "user-id" });

Get user groups

Get user groups
const roles = await keycloakAdminClient.users.listGroups({ id: "user-id" });

Find all realm groups

Find all realm groups
const groups = await keycloakAdminClient.groups.find();

Find a single group

Find a single group
const group = await keycloakAdminClient.groups.findOne({ id: "group-id" });