java Spring Oauth2.0 缺少授权类型

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39366281/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 04:19:08  来源:igfitidea点击:

Spring Oauth2.0 Missing grant type

javaspringspring-securityspring-security-oauth2

提问by Parth Solanki

I am using Spring Oauth 2.O.

我正在使用 Spring Oauth 2.O。

When I pass request as a form-data it works fine, but when I try to pass data in application/jsonformat it gives me error missing grant type.

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

Request

要求

http://localhost:8080/oauth/token

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

Error I getting.

我得到的错误。

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

Please Guide.

请指导。

回答by Prasanna Kumar H A

OAuth2doesn't support JSONin the access token request.You can check here for description..It requires application/x-www-form-urlencoded

OAuth2不支持JSON访问令牌请求。您可以在此处查看说明..它需要application/x-www-form-urlencoded