I’m totally new to keycloak and trying to create a new realm via the admin cli. I can authenticate to the master realm, configure it, and create other realms. But I can’t configure those other realms, I just get a 401 unauthorised error. And since the other realms have no users I can’t authenticate to them directly. Here is an example trying to add a user to a newly created realm. Everything works except that last command. How could this be solved?
KCADM=/path-to/bin/kcadm.sh
KCADM_SERVER=http://localhost:80
ADMIN_USERNAME=theAdmin
ADMIN_PASSWORD=adminKey
# Authenticate
$KCADM config credentials \
--server $KCADM_SERVER \
--user $ADMIN_USERNAME \
--password $ADMIN_PASSWORD \
--realm master \
--client admin-cli
REALM_NAME=second_realm
$KCADM create realms \
--server $KCADM_SERVER \
-s realm=${REALM_NAME} \
-s enabled=true
$KCADM create users \
--server $KCADM_SERVER \
--realm $REALM_NAME \
-s username="aNewUsername" \
-s enabled=true \
-s firstName="New" \
-s lastName="User" \
-s email="new.user@example.com"