Skip to content

Instantly share code, notes, and snippets.

@rhopp
Last active July 24, 2019 10:45
Show Gist options
  • Save rhopp/b0bd33590cde46c6acdf66cad53a689e to your computer and use it in GitHub Desktop.
Save rhopp/b0bd33590cde46c6acdf66cad53a689e to your computer and use it in GitHub Desktop.
#/bin/bash
ADMIN_USERNAME=admin
ADMIN_PASS=admin
KEYCLOAK_BASE_URL=http://keycloak-rhopp-che-test1.apps.crw.codereadyqe.com/auth
echo "Getting admin token"
ADMIN_ACCESS_TOKEN=$(curl -X POST $KEYCLOAK_BASE_URL/realms/master/protocol/openid-connect/token -H "Content-Type: application/x-www-form-urlencoded" -d "username=admin" -d "password=admin" -d "grant_type=password" -d "client_id=admin-cli" |jq -r .access_token)
echo $ADMIN_ACCESS_TOKEN
echo "Creating user"
USER_JSON=$(cat <<EOF
{
"username": "testUser",
"enabled": true,
"emailVerified": true
}
EOF
)
echo $USER_JSON
# User already created. Skip this step.
#curl -X POST $KEYCLOAK_BASE_URL/admin/realms/che/users -H "Authorization: Bearer ${ADMIN_ACCESS_TOKEN}" -H "Content-Type: application/json" -d "${USER_JSON}" -v
echo "Updating password"
USER_ID=76f2a744-e822-4bad-ad67-b6e08a5e7fe8
CREDENTIALS_JSON=$(cat <<EOF
{
"type":"password",
"value":"testUser",
"temporary":false
}
EOF
)
echo $CREDENTIALS_JSON
curl -X PUT $KEYCLOAK_BASE_URL/admin/realms/che/users/${USER_ID}/reset-password -H "Authorization: Bearer ${ADMIN_ACCESS_TOKEN}" -H "Content-Type: application/json" -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment