I want to create a realm in Keycloak using the REST Admin APIs. Below is what I have done until now
In the
masterrealm, create a new clientcustom-admin-api.In the
Service accounts rolesof the client, assign the role ofrealm-admin.Generate the
access_tokenusing theclient-idandclient-secret. The token has the below roles.{"resource_access":{"realm-management":{"roles":["view-identity-providers","view-realm","manage-identity-providers","impersonation","realm-admin","create-client","manage-users","query-realms","view-authorization","query-clients","query-users","manage-events","manage-realm","view-events","view-users","view-clients","manage-authorization","manage-clients","query-groups"]}}}Create the realm. I get an error response.
curl --location 'https://my-keycloak/auth/admin/realms' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer e...mFGA' \
--data '{
"realm": "test",
"displayName": "Test",
"enabled": true
}'
403
{"error":"unknown_error"}
Can anyone guide me on what changes I need to make to create a new Realm?
Note: I'm able to create new users with the same access_token.
This way can do create realm by user's token
1. In the master realm, create
custom-admin-apiclientAnd 'create-role` with create-realm.
1. In the master realm, create a new power-user (password: 1234).
And
Assign Rolewithcreate-realmAfter Assign
Create Realm by Postman
Step 1. Tests Tab, setting
Step 2. Body Setting
Step 3 Get access-token URL
Step 5 Create Realm
Setting Token
Body
Result
Create Realm by Curl
Get access token at Git Bash
Print access token
Create realm
Result