oauth-2.0 - 从 Keycloak 令牌端点获取授权码
问题描述
在 keycloak 文档中写道,令牌端点可用于 在授权代码流中获取临时代码,或用于通过隐式流、直接授予或客户端授予获取令牌。
但即使使用 response_type=code ,我也无法获得授权码:只有一个令牌。我怎样才能做到这一点?
我的测试要求:
curl -X POST \
http://localhost:8080/auth/realms/my-realm/protocol/openid-connect/token \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Host: localhost:8080' \
-H 'Postman-Token: e103dff9-7b25-4f8f-886b-2af73efee561,e8f92a85-1489-4d7f-b89f-76cfe85e9c68' \
-H 'User-Agent: PostmanRuntime/7.15.0' \
-H 'accept-encoding: gzip, deflate' \
-H 'cache-control: no-cache' \
-H 'content-length: 94' \
-d 'grant_type=password&username=login&password=pwd&client_id=my-app&response_type=code'
来源:https ://www.keycloak.org/docs/latest/server_admin/index.html#keycloak-server-oidc-uri-endpoints
解决方案
response_type
只能在对授权端点(http://localhost:8080/auth/realms/my-realm/protocol/openid-connect/auth
)的授权请求中使用,在这种情况下(在令牌请求中)将被忽略。授权码可以从授权端点获取,如下所示:
http://localhost:8080/auth/realms/my-realm/protocol/openid-connect/auth?client_id=my-ap&redirect_uri=https://...&response_type=code
推荐阅读
- flutter - 使用 bottomSheet 时脚手架主体不可见
- forms - VueJs 温度验证
- spring - 存储库未启动
- javascript - 带有使用 es6 模块的外部库的打字稿
- sql - 合并两个 SQL 查询以在单个表中获取输出
- javascript - 如何获取参数函数javascript
- lua - 在 Windows 10 上设置 luarocks
- google-sheets-api - google.Script.run 未返回有关 DOMContentLoaded 执行的数据
- pytorch - 带有pytorch的resnet50中缺少/意外的键
- excel - 检查单元格的百分比格式