无法访问 keycloak rest API 方法 *404*

Cant access keycloak rest API methods *404*

我在 docker 中使用最新的 keycloak 映像,并且可以在 http://localhost:9080. However, I cant seem to access any of the paths specified in the documentation for Admin REST api. For instance, the base path /auth and Resource Get clients belonging to the realm Returns a list of clients belonging to the realm: /{realm}/clients I am getting a 404. So is for any other method in the documentation. The only path returning a valid 200 json response is http://localhost:9080/auth/realms/{realm-name}/ 访问标准管理控制台,根据文档可以在基本路径+“/{领域名称}”。我是否遗漏了什么或试图使用错误的基本路径进行访问。 docker 中的 keycloak 版本是 3.4。3.Final 根据文档,这是 keycloak 的最新版本。

我几乎可以肯定您正在尝试这样调用端点:

http://localhost:9080/auth/admin/realms/demo/clients

但是,您错过了这一部分/auth/admin/realms

请不要忘记先按照说明授权您的通话here

更新

这是我查看结果的步骤:

$ docker run -d -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin jboss/keycloak

获取access_token:

$ curl -X POST \
    -H 'Content-Type: application/x-www-form-urlencoded' \
    -d 'username=admin&password=admin&client_id=admin-cli&grant_type=password' \
    http://localhost:9080/auth/realms/master/protocol/openid-connect/token  

将获得的 access_token 复制并粘贴到 Authorization header:

$ curl -X GET \
    -H 'Authorization: Bearer <access_token_goes_here>' \
    http://localhost:9080/auth/admin/realms/master/clients

他们现在更新为:

http://localhost:9080/realms/demo/clients

我挣扎了一整天才发现它与文档中所说的不一样。

可以在领域设置下的 Keycloak 控制台上找到配置端点。在端点部分,它将显示您需要的所有端点。

在17.0.1版本使用restAPI我最终想出了:

http://localhost:8080/admin/realms/{realm name}/clients