Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keycloak create clientscope with a particular type using REST API

I wanted to create a custom scope in Keycloak with the default type. I tried the following request on Kecloak 19.0.2 version

POST  http://localhost:8080/auth/admin/realms/master/client-scopes

{
  "attributes": {
    "display.on.consent.screen": "false",
    "include.in.token.scope": "false",
        "gui.order": "1"
  },
  "name": "example",
  "description": "example",
  "type": "default",
  "protocol": "saml"
}

But it is always created with type None.

enter image description here

This is the same request Keycloak uses when created from UI

enter image description here

like image 666
Sirish Avatar asked Dec 07 '25 04:12

Sirish


1 Answers

You needs to call this API after call POST /{realm}/client-scopes

Here is document

PUT /{realm}/default-default-client-scopes/{clientScopeId}

enter image description here

Demo by curl

Get master token by curl

curl --location --request PUT 'http://localhost:8080/auth/admin/realms/master/default-default-client-scopes/80854f36-5646-4fb4-aeca-581b18064c54' \
--header 'Authorization: Bearer '"$MASTER_TOKEN"

Then you can see the result from UI.

enter image description here

The clientScopeId get from GET /{realm}/client-scopes API

enter image description here

Client Scopes's Body parameter do not include type enter image description here

enter image description here

like image 198
Bench Vue Avatar answered Dec 09 '25 21:12

Bench Vue