DEV Community

loading...

Keycloak: REST API for Realm Role

rounakcodes
Self taught. Full Stack Developer. More than 4 years of experience. Currently working on scaling a SaaS product.
・1 min read

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"
Enter fullscreen mode Exit fullscreen mode

Create a Realm Role

  • Code
  curl -X POST http://localhost:8080/auth/admin/realms/<realm-id>/roles \
  -H "Authorization: Bearer ${TOKEN}" \
  -H 'Content-Type: application/json' \
  -d '{"name": "<role-name>"}'
Enter fullscreen mode Exit fullscreen mode

Get all Realm Roles

  • Code
  curl -X GET http://localhost:8080/auth/admin/realms/<realm-id>/roles \
  -H "Authorization: Bearer ${TOKEN}" \
Enter fullscreen mode Exit fullscreen mode

Discussion (0)