DEV Community

rounakcodes
rounakcodes

Posted on

10 2

Keycloak: REST API for Realm Role

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

Top comments (1)

Collapse
 
hendisantika profile image
Hendi Santika

Is there any way to list all realm & client roles by REST API ADMIN via Java?

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay