snippets_js
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 groups = 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" });