Skip to content

Instantly share code, notes, and snippets.

@longdog
Last active May 4, 2023 07:46
Show Gist options
  • Save longdog/10b3f011c36cd9e0b7a5a77387ccec95 to your computer and use it in GitHub Desktop.
Save longdog/10b3f011c36cd9e0b7a5a77387ccec95 to your computer and use it in GitHub Desktop.
keycloak add users by curl
access_token=`curl -d "client_id=admin-cli" -d "client_secret=#####" -d "grant_type=client_credentials" "http://localhost:8080/realms/my-realm/protocol/openid-connect/token" | jq -r .access_token`
curl -X POST -H "Authorization: Bearer $access_token" -H 'Accept: application/json' -H 'Content-Type: application/json' -d @u.json http:/localhost:8080/admin/realms/my-realm/partialImport
  • Open the "admin-cli" client in your realm (my-realm)
  • In the Service Accounts Roles assing "realm-admin" and "manage users" roles
{
"users": [
{
"username": "ivan",
"email": "test@test.com",
"firstName": "Ivan",
"lastName": "Ivanov",
"emailVerified": true,
"enabled": true
}
],
"policy": "SKIP"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment