Keycloak: Create a new Realm using REST API

Get access token

Code

curl \
-d “client_id=admin-cli” \
-d “username=admin” \
-d “password=admin” \
-d “grant_type=password” \
“http://localhost:8080/auth/realms/master/protocol/openid-connect/token”

Create re…


This content originally appeared on DEV Community and was authored by rounakcodes

Get access token

  • Code
  curl \
  -d "client_id=admin-cli" \
  -d "username=admin" \
  -d "password=admin" \
  -d "grant_type=password" \
  "http://localhost:8080/auth/realms/master/protocol/openid-connect/token"

Create realm json file

  • Sample
  {
    "id": "newrealm",
    "realm": "newrealm",
    "displayName": "New Realm",
    "enabled": true,
    "sslRequired": "external",
    "registrationAllowed": false,
    "loginWithEmailAllowed": true,
    "duplicateEmailsAllowed": false,
    "resetPasswordAllowed": false,
    "editUsernameAllowed": false,
    "bruteForceProtected": true
  }

Create realm

  • Code
  curl -v POST \
    -H "Authorization: Bearer <access-token>" \
    -H "Content-Type: application/json" \
    -d "@<realm-file>" \ http://localhost:8080/auth/admin/realms


This content originally appeared on DEV Community and was authored by rounakcodes


Print Share Comment Cite Upload Translate Updates
APA

rounakcodes | Sciencx (2021-06-16T11:09:48+00:00) Keycloak: Create a new Realm using REST API. Retrieved from https://www.scien.cx/2021/06/16/keycloak-create-a-new-realm-using-rest-api/

MLA
" » Keycloak: Create a new Realm using REST API." rounakcodes | Sciencx - Wednesday June 16, 2021, https://www.scien.cx/2021/06/16/keycloak-create-a-new-realm-using-rest-api/
HARVARD
rounakcodes | Sciencx Wednesday June 16, 2021 » Keycloak: Create a new Realm using REST API., viewed ,<https://www.scien.cx/2021/06/16/keycloak-create-a-new-realm-using-rest-api/>
VANCOUVER
rounakcodes | Sciencx - » Keycloak: Create a new Realm using REST API. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/06/16/keycloak-create-a-new-realm-using-rest-api/
CHICAGO
" » Keycloak: Create a new Realm using REST API." rounakcodes | Sciencx - Accessed . https://www.scien.cx/2021/06/16/keycloak-create-a-new-realm-using-rest-api/
IEEE
" » Keycloak: Create a new Realm using REST API." rounakcodes | Sciencx [Online]. Available: https://www.scien.cx/2021/06/16/keycloak-create-a-new-realm-using-rest-api/. [Accessed: ]
rf:citation
» Keycloak: Create a new Realm using REST API | rounakcodes | Sciencx | https://www.scien.cx/2021/06/16/keycloak-create-a-new-realm-using-rest-api/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.