[keycloak-user] keycloak update/create realm with localization

Dennis Knorr dennis.knorr at gmx.net
Wed Jun 12 04:54:48 EDT 2019


Hi,
i try to create/update a realm with de localization. therefore i enable
internationalization, set defaultLocale to de and set themes to
keycloak, with clicking in the AdminUI this works.

When i try to update an existing realm with the following script, it
does not work. neither with POST or PUT. Any idea what i do wrong? any
tips how to do creating/updating realms properly via REST API? This is
harder than i expected.

###########################################################
benutzer01 at vm:~/keycloakscripts$ cat scripts/update_realm.sh
#!/bin/bash

set -o noclobber
set -o errexit
set -o pipefail
set -o nounset

# Debugging
#set -xv

if [[ $# -lt 2 ]]; then
     cat <<EOF
         usage:
             $0 ENVIRONMENT REALMNAME
EOF
     exit 1
fi

# sourcing ENV files
source scripts/_header.sh

REALM=$2

ADMINTOKEN=$(curl -s \
     -d "client_id=admin-cli" \
     -d "username=${KEYCLOAK_USER}" \
     -d "password=${KEYCLOAK_PASSWORD}" \
     -d "grant_type=password" \

"https://${APP_URL}/auth/realms/master/protocol/openid-connect/token" |
jq -r .access_token)
echo "admin token successfully acquired"

curl -s \
     -X PUT
     -H "Authorization:bearer ${ADMINTOKEN}" \
     -H 'Content-Type: application/json' \
     -d "@$REALM/${SCRIPT_PARAMETER}/realm.json" \
     "https://${APP_URL}/auth/admin/realms"
echo "realm '$REALM' update"

benutzer01 at vm:~/keycloakscripts$ cat myrealm/MYENV/realm.json
{
     "realm": "myrealm",
     "enabled": true,
     "requiredCredentials": [
         "password"
     ],
     "accessTokenLifespan": 7200,
     "eventsEnabled": true,
     "eventsExpiration": 7200,
     "internationalizationEnabled": true,
     "loginTheme": "keycloak",
     "accountTheme": "keycloak",
     "adminTheme": "keycloak",
     "emailTheme": "keycloak",
     "defaultLocale": "de"
}
benutzer01 at vm:~/keycloakscripts$ scripts/update_realm.sh MYENV myrealm
# this should change the settings for myrealm.
##########################################



More information about the keycloak-user mailing list