gpt4 book ai didi

spring-boot - 无法从 KeyCloak 获取访问 token

转载 作者:行者123 更新时间:2023-12-02 03:05:54 26 4
gpt4 key购买 nike

我正在尝试使用 postman 从 Keycloak 服务器获取访问 token 。

我一直在关注这个link并创建了教程中提到的领域、用户、角色凭据。

但是当我发出请求时,它会无限期地继续下去,不会返回任何东西。

编辑:我也尝试将 grant_type 作为“密码”和“client_credentials”。但运气不好。

enter image description here

最佳答案

这是从PostMan获取Token的正确方法

https://<IP ADDRESS>:<PORT>/auth/realms/master/protocol/openid-connect/token

在正文部分选择x-www-form-urlencoded

{
"username": "username",
"password": "password",
"client_id": "APP-NAME",
"grant_type": "password",
"client_secret": "462fe347-d47f-4365-94ee-6aefff994ef2"
}

要获得更明确的解决方案,请像这样使用 enter image description here

If you want to from through `curl` command then use below command 
curl -X POST -k -H 'Content-Type: application/x-www-form-urlencoded' -i 'https://<IP>:<PORT>/auth/realms/master/protocol/openid-connect/token' --data 'username=username&password=password&client_id=CLIENT-ID&grant_type=password&client_secret=462fe347-d47f-4365-94ee-6aefff994ef2'

**编辑**

正如在 SO 聊天中与 OP 讨论的最后找到解决方案一样,OP 正在创建具有临时密码的用户,因此每次用户登录时它都必须更改密码,这就是它失败的原因。在 OP 更改禁用选项后它开始工作 enter image description here

关于spring-boot - 无法从 KeyCloak 获取访问 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59027063/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com