keycloak - 如何通过 REST API 删除 Keycloak 领域

标签 keycloak keycloak-rest-api

我无法通过 Keycloak 8.0.2 上的 REST API 删除领域。

我的 Keycloak 在 localhost:38080 上运行。我遵循了这个文档 https://www.keycloak.org/docs-api/8.0/rest-api/index.html#_realms_admin_resource ,请参阅“删除领域”段落。首先,我在 http://localhost:38080/auth/realms/master/protocol/openid-connect/token 获得了管理员用户的 token

curl --location --request POST 'localhost:38080/auth/realms/master/protocol/openid-connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=admin' \
--data-urlencode 'password=admin' \
--data-urlencode 'client_id=vga_tests' \
--data-urlencode 'grant_type=password'

然后我使用 token 并尝试通过此调用删除 example 领域

curl --location --request DELETE 'localhost:38080/auth/Example' \
--header 'Authorization: Bearer <TOKEN HERE>' \
--header 'Content-Type: application/json' \
--data-raw ''

(注意:curl 命令是导出的 Postman 调用)

我收到了这个 404 响应

{
    "error": "RESTEASY003210: Could not find resource for full path: http://localhost:38080/auth/Example"
}

我做错了什么?

最佳答案

文档不正确,我需要发送DELETE请求的地址是localhost:38080/auth/admin/realms/example

curl 命令:

curl --location --request DELETE 'localhost:38080/auth/admin/realms/example' \
--header 'Authorization: Bearer <TOKEN HERE>' \
--header 'Content-Type: application/x-www-form-urlencoded'

关于keycloak - 如何通过 REST API 删除 Keycloak 领域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60601560/

相关文章:

java - 在 Keycloak 中以编程方式创建客户端

java - 配置在测试中被忽略

node.js - 撤销 Keycloak 访问 token

php - keycloak-传递参数满足密码策略要求

openid-connect - Keycloak:在 JSON 中获取授权码?

flask - 将 KeyCloak(OpenID Connect) 与 Apache SuperSet 结合使用

oauth-2.0 - Keycloak 无效的 token 发行者

node.js - 使用 Keycloak Rest API 将用户添加到客户端角色

java - 我无法在 Keycloak 适配器中启动主体