我无法通过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
获得了管理员用户的令牌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'
然后我使用令牌并尝试通过此调用删除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"
}
我在做什么错了?
答案 0 :(得分:2)
文档不正确,我将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'
答案 1 :(得分:0)
或者,使用 CLI interface(搜索“删除领域”), 你可以这样做:
$ kcadm.sh delete realms/example