我正在尝试在Keycloak的领域中添加角色,但这给了我错误的请求响应。我的步骤:
curl -X POST "http://localhost:8180/auth/realms/master/protocol/openid-connect/token" \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'username=admin&password=admin&grant_type=password&client_id=admin-cli'
curl -X GET http://localhost:8180/auth/admin/realms/my-realm/clients?clientId=my-client \
-H "Authorization: Bearer "$access_token \
-H 'cache-control: no-cache'
curl -v http://localhost:8180/auth/admin/realms/my-realm/clients/[ID-from-above]/roles \
-H "Content-Type: application.json" \
-H "Authorization: Bearer "$access_token --data '{"name":"test-role"}'
当我发出最后一条命令时,我得到了错误的请求响应。我究竟做错了什么?谢谢你。
https://www.keycloak.org/docs-api/5.0/rest-api/index.html#_roles_resource
你似乎很接近。
我可以通过遵循REST API来创建领域级别的角色:
此呼叫与你的呼叫之间的区别在于,你想充当客户端级别的角色。你是否对客户端级别角色有特定要求,或者你只是在尝试?
如果领域级别的角色满足你的要求,则可以使用上述API。
另请检查此帖子,以确保你已正确按照步骤进行操作,以设置admin Rest API。