我在我的本地机器上独立运行了 keycloak。
我创建了名为“spring-test”的新领域,然后创建了名为“login-app”的新客户端
根据其余文档:
POST: http://localhost:8080/auth/realms/spring-test/protocol/openid-connect/token
{
"client_id": "login-app",
"username": "user123",
"password": "pass123",
"grant_type": "password"
}
应该给我 jwt token ,但我收到错误的响应请求
{
"error": "invalid_request",
"error_description": "Missing form parameter: grant_type"
}
我假设我的配置中缺少某些东西。
编辑:
我使用的是 json 正文,但它应该是 application/x-www-form-urlencoded
:
以下 body 工作:
token_type_hint:access_token&token:{token}&client_id:{client_id}&client_secret:{client_secret}
最佳答案
您应该在 POST 请求中发送您的数据,并将 Content-Type
header 值设置为 application/x-www-form-urlencoded
,而不是 json。
关于java - Keycloak 缺少表单参数 : grant_type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53795179/