bin/kc.[sh|bat] start --features=client-admin-api-v2
| This feature is experimental and may introduce breaking changes in future versions of Keycloak. Do not use this feature in production environments. |
The Admin API v2 requires the client-admin-api-v2 feature:
bin/kc.[sh|bat] start --features=client-admin-api-v2
Add the dependency to your project:
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
</dependency>
import org.keycloak.admin.client.Keycloak;
Keycloak adminClient = Keycloak.getInstance("http://localhost:8080", "master", "admin", "password", "admin-cli");
npm install @keycloak/keycloak-admin-client
import KcAdminClient from "@keycloak/keycloak-admin-client";
const kcAdminClient = new KcAdminClient({ baseUrl: "http://localhost:8080", enableExperimentalApis: true });
await kcAdminClient.auth({ username: "admin", password: "admin", grantType: "password", clientId: "admin-cli" });
The Admin API v2 uses the same CLI tool described in the Server Administration Guide with the --v2 flag:
bin/kcadm.[sh|bat] --v2 config credentials --server http://localhost:8080 --realm master --user admin
import org.keycloak.admin.api.client.ClientsApi;
import org.keycloak.admin.api.AdminApi;
AdminApi adminApi = adminClient.proxy(AdminApi.class);
ClientsApi clientsApi = adminApi.clientsV2();
/admin/api/{realmName}/clients/v2Get all clients
Returns a list of clients in the realm, optionally filtered by a query expression
| Name | Description |
|---|---|
fields |
Set of fields to include in the response. Must be top-level fields. If omitted or empty, all fields will be populated. |
q |
Filter expression using SCIM-like syntax, e.g. clientId eq "my-app" and enabled eq true |
| Code | Type | Description |
|---|---|---|
200 |
array<OIDCClientRepresentation>, array<SAMLClientRepresentation> |
OK |
/admin/api/{realmName}/clients/v2Create a new client
Creates a new client in the realm
| Name | protocol |
|---|---|
OIDCClientRepresentation |
|
SAMLClientRepresentation |
|
/admin/api/{realmName}/clients/v2/{id}Get a client
Returns a single client by its clientId
/admin/api/{realmName}/clients/v2/{id}Create or update a client
Creates or updates a client in the realm
| Name | protocol |
|---|---|
OIDCClientRepresentation |
|
SAMLClientRepresentation |
|
/admin/api/{realmName}/clients/v2/{id}Patch a client
Partially updates a client using JSON Merge Patch
PATCH /admin/api/{realmName}/clients/v2/{id} HTTP/1.1
Content-Type: application/merge-patch+json
A partial representation containing the fields to update. Required fields must always be included.
| Name | protocol |
|---|---|
|
|
|
| Name | Type | Description |
|---|---|---|
uuid |
string |
UUID generated by the server. Validation: on update/on patch: UUID is server-managed and must not be user-specified |
clientId |
string |
ID uniquely identifying this client. Validation: must not be blank; size must be between 1 and 255 |
displayName |
string |
Human readable name of the client. Validation: size must be between 0 and 255 |
description |
string |
Human readable description of the client. Validation: size must be between 0 and 255 |
enabled |
boolean |
Whether this client is enabled |
appUrl |
string |
URL to the application’s homepage that is represented by this client. Validation: size must be between 0 and 255; must be a valid URL |
redirectUris |
array<string> |
URIs that the browser can redirect to after login. Validation: size must be between 0 and 100; each element must not be blank, size must be between 0 and 255; Invalid redirect URI |
roles |
array<string> |
Roles associated with this client. Validation: size must be between 0 and 300; each element must not be blank, size must be between 0 and 255 |
protocol |
string |
Discriminator. Allowed values: |
Extends BaseClientRepresentation.
| Name | Type | Description |
|---|---|---|
loginFlows |
array<Flow> |
Login flows that are enabled for this client. Validation: SERVICE_ACCOUNT and TOKEN_EXCHANGE flows require a confidential client (auth must be specified); STANDARD and IMPLICIT flows require at least one redirect URI |
auth |
Authentication configuration for this client |
|
webOrigins |
array<string> |
Web origins that are allowed to make requests to this client. Validation: size must be between 0 and 100; each element must not be blank, size must be between 0 and 255, must be a valid web origin (scheme://host[:port]), or '+' to derive from redirect URIs, or '*' to allow all |
serviceAccountRoles |
array<string> |
Roles assigned to the service account. Validation: size must be between 0 and 300; each element must not be blank, size must be between 0 and 255; serviceAccountRoles can only be set when SERVICE_ACCOUNT flow is enabled |
protocol |
string |
Fixed value: |
| Name | Type | Description |
|---|---|---|
method |
string |
Which authentication method is used for this client. Validation: must not be blank; valid client authenticator type is required |
secret |
string |
Secret used to authenticate this client with Secret authentication. Validation: size must be between 6 and 255; on update: Client secret must not be blank |
certificate |
string |
Public key used to authenticate this client with Signed JWT authentication. Validation: size must be between 0 and 65536 |
Extends BaseClientRepresentation.
| Name | Type | Description |
|---|---|---|
nameIdFormat |
Name ID format to use for the subject |
|
forceNameIdFormat |
boolean |
Force the specified Name ID format even if the client requests a different one |
includeAuthnStatement |
boolean |
Include AuthnStatement in the SAML response |
signDocuments |
boolean |
Sign SAML documents on the server side |
signAssertions |
boolean |
Sign SAML assertions |
clientSignatureRequired |
boolean |
Require client to sign SAML requests |
forcePostBinding |
boolean |
Force POST binding for SAML responses |
frontChannelLogout |
boolean |
Use front-channel logout (browser redirect) |
signatureAlgorithm |
Signature algorithm for signing SAML documents |
|
signatureCanonicalizationMethod |
string |
Canonicalization method for XML signatures. Validation: must be a valid XML canonicalization method URI (see javax.xml.crypto.dsig.CanonicalizationMethod constants) |
signingCertificate |
string |
X.509 certificate for signing (PEM format, without headers). Validation: size must be between 0 and 65536 |
allowEcpFlow |
boolean |
Allow ECP (Enhanced Client or Proxy) flow |
protocol |
string |
Fixed value: |