A comprehensive TypeScript client library for interacting with Keycloak's Administration API.
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
The WhoAmI resource provides information about the currently authenticated admin user, including their permissions, roles, and access levels within the Keycloak admin console.
Retrieve information about the currently authenticated admin user.
/**
* Get information about the currently authenticated admin user
* @param params - Parameters containing the current realm context
* @returns WhoAmI representation with user information and permissions
*/
find(params: { currentRealm: string }): Promise<WhoAmIRepresentation>;import KeycloakAdminClient from "@keycloak/keycloak-admin-client";
const kcAdminClient = new KeycloakAdminClient({
baseUrl: 'http://localhost:8080',
realmName: 'master',
});
await kcAdminClient.auth({
username: 'admin',
password: 'admin',
grantType: 'password',
clientId: 'admin-cli',
});
// Get current user information
const whoAmI = await kcAdminClient.whoAmI.find({
currentRealm: 'myrealm'
});
console.log('Current user:', whoAmI.userId);
console.log('Display name:', whoAmI.displayName);
console.log('Realm access:', whoAmI.realmAccess);
console.log('Resource access:', whoAmI.resourceAccess);interface WhoAmIRepresentation {
userId?: string;
realm?: string;
displayName?: string;
locale?: string;
createRealm?: boolean;
realmAccess?: Record<string, boolean>;
resourceAccess?: Record<string, Record<string, boolean>>;
}docs