Keycloak缺少表单参数:grant_type [英] Keycloak Missing form parameter: grant_type

查看:542
本文介绍了Keycloak缺少表单参数:grant_type的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地计算机上运行了独立的keycloak.

I have keycloak standalone running on my local machine.

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

I created new realm called 'spring-test', then new client called '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令牌,但是我收到了带有响应的错误请求

should give me the jwt token but I get bad request with response

{
    "error": "invalid_request",
    "error_description": "Missing form parameter: grant_type"
}

我假设我的配置中缺少某些东西.

I am assuming that something is missing in my configuration.

我正在使用json正文,但应该为application/x-www-form-urlencoded: 以下身体起作用:

I was using json body but it should be application/x-www-form-urlencoded: the following body works:

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

推荐答案

您应在POST请求中发送数据,并将标头值设置为application/x-www-form-urlencoded,而不是json.

You should send your data in a POST request with Content-Type header value set to application/x-www-form-urlencoded, not json.

这篇关于Keycloak缺少表单参数:grant_type的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆