【问题标题】:Spring Oauth2.0 Missing grant typeSpring Oauth2.0 缺少授权类型
【发布时间】:2017-01-14 22:20:41
【问题描述】:

我正在使用 Spring Oauth 2.O。

当我将请求作为表单数据传递时,它工作正常,但是当我尝试以 application/json 格式传递数据时,它给我错误缺少授权类型。

请求

http://localhost:8080/oauth/token

{"username":"parths","password":"123456","grant_type":"password"}

我遇到了错误。

{
  "status": "0",
  "message": "Missing grant type"
}

请指导。

【问题讨论】:

    标签: java spring spring-security spring-security-oauth2


    【解决方案1】:

    OAuth2不支持JSON在访问令牌请求中。您可以检查here for description..它需要application/x-www-form-urlencoded

    【讨论】:

      【解决方案2】:

      除了 Prasanna Kumar,我想补充一点,您需要以 application/x-www-form-urlencoded 类型的主体发送数据,例如 KEY-VALUE
      可以查看的授权类型here

      【讨论】:

        猜你喜欢
        • 2017-12-11
        • 2018-05-03
        • 1970-01-01
        • 2019-10-13
        • 2018-09-11
        • 1970-01-01
        • 1970-01-01
        • 2021-07-25
        • 2016-02-10
        相关资源
        最近更新 更多