如何测试Keycloak本机服务?
文档提供了几种服务,例如:用户管理、客户、组和会话,我尝试过以多种方式测试这些服务,但没有成功。可能是因为配置不正确
我看到了Stackoverflow上的一个示例,它显示了服务的正确路径。
Eg. http://{address-and-port}/auth/admin/realms/{Realm}/users
和一些关于如何在邮递员上测试的设置,但是我没有成功地调用
是否有人有示例,或可以帮助我如何激活/使用这些服务。
,谢谢!
要消费的服务:() https://www.keycloak.org/docs-api/8.0/rest-api/index.html](https://www.keycloak.org/docs-api/8.0/rest-api/index.html])
发布于 2020-02-06 20:00:07
我给你导出了一个邮递员集:https://pastebin.com/Aaf3BUah,你可以把它导入邮递员。
但我想指出的是,如何使用API:
我的示例在http://localhost:80上使用一个正在运行的密钥披风实例(8.0.2),并使用用户admin和密码Pa55w0rd
其中包括2项请求:
登录:
与我的管理用户登录并获取请求2中使用的访问令牌。
POST http://localhost:80/auth/realms/master/protocol/openid-connect/token
Content-Type:x-www-form-urlencoded使用以下参数(更改用户名/密码)
username:admin
password:Pa55w0rd
grant_type:password
client_id:admin-cli因此,我将获得一些数据,但重要的是access_Token:
{
"access_token": "eyJhbGc...JDjfg", //i reduced the string
...
}请记住,这个令牌是执行Request2所必需的。但是它只有效60秒,所以在测试时要快速:-)
让所有用户:
GET http://localhost:80/auth/admin/realms/master/users
Header Authorization: Bearer eyJhbGc...JDjfg响应:
[
{
"id": "9fec4b6c-3648-425b-a90f-f6dd78f421ab",
"createdTimestamp": 1581017581626,
"username": "admin",
"enabled": true,
"totp": false,
"emailVerified": false,
"disableableCredentialTypes": [],
"requiredActions": [],
"notBefore": 0,
"access": {
"manageGroupMembership": true,
"view": true,
"mapRoles": true,
"impersonate": true,
"manage": true
}
}
]在这个例子中,您应该能够访问不同的REST端点。但是,请确保在发送的每个请求中都包含一个有效的access_token,否则只会得到Not Authorized响应。
发布于 2020-11-29 14:44:12
这是完整的邮递员管理Rest API。
https://documenter.getpostman.com/view/7294517/SzmfZHnd
它是为键盘斗篷10 (但工作为11太测试)
在邮递员中打开它,用您的keycloak主机和params来调整环境变量。
您将获得一个完整的功能密钥斗篷管理rest。
https://stackoverflow.com/questions/60100695
复制相似问题