Keycloak缺少表单参数:grant_type

6 浏览
0 Comments

Keycloak缺少表单参数:grant_type

我在本地机器上运行了独立的Keycloak。

我创建了一个名为'spring-test'的新领域,然后创建了一个名为'login-app'的新客户端。

根据REST文档:

POST:http://localhost:8080/auth/realms/spring-test/protocol/openid-connect/token

{

"client_id": "login-app",

"username": "user123",

"password": "pass123",

"grant_type": "password"

}

应该给我返回JWT令牌,但我收到了错误请求的响应:

{

"error": "invalid_request",

"error_description": "Missing form parameter: grant_type"

}

我猜测我的配置中缺少了一些内容。

编辑:

我之前使用的是JSON格式的请求体,但应该使用application/x-www-form-urlencoded格式:

以下请求体有效:

token_type_hint:access_token&token:{token}&client_id:{client_id}&client_secret:{client_secret}

0