无法访问keycloak rest API方法* 404 * [英] Cant access keycloak rest API methods *404*

查看:375
本文介绍了无法访问keycloak rest API方法* 404 *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在docker中使用最新的keycloak映像,并且可以通过 http://localhost:9080 访问标准管理控制台. .但是,我似乎无法访问文档中指定的任何路径(用于Admin REST api).例如,基本路径/auth 和资源获取属于该领域的客户端将返回属于该领域的客户端列表: /{realm}/clients 我得到404. http://localhost:9080/auth/realms/ {realm-name}/,根据文档,可以在basepath +"/{realm-name}"处找到它.我是否缺少某些内容或试图使用错误的基本路径进行访问? docker中的keycloak版本为3.4.3.Final,根据文档,这是keycloak的最新版本.

I am using the latest keycloak image in docker and can access the standard admin console at 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}/ which according to the documentation be reachable at basepath + "/{realm-name}". Am I missing something or trying to access with a wrong base path. The keycloak version in docker is 3.4.3.Final which is the latest version of keycloak according to the documentation.

推荐答案

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

I'm almost sure you are trying to call the endpoint like this:

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

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

However, you've missed this part/auth/admin/realms

请不要忘记按照此处

更新

这是我查看结果的步骤:

Here are my steps to see the results:

$ 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标头中:

Copy and paste obtained access_token to Authorization header:

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

这篇关于无法访问keycloak rest API方法* 404 *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆