邮递员oAuth2错误未授权的授权类型

时间:2016-10-14 04:31:56

标签: java oauth-2.0 postman oauth2

我有一个使用oAuth2的应用程序,我尝试使用此命令从终端请求访问令牌

curl -X POST -vu clientapp:123456 http://localhost:8080/oauth/token -H "Accept: application/json" -d "password=spring&username=roy&grant_type=password&scope=read%20write&client_secret=123456&client_id=clientapp"

它工作正常,我得到这样的回复

{"access_token":"29c4c218-1d9a-4d2d-abe3-197bc2969679","token_type":"bearer","refresh_token":"6b7ffda7-4652-4197-b8e9-c80635eb9143","expires_in":38630,"scope":"read write"}

但问题是当我尝试通过邮递员请求访问令牌时总是会收到此错误:

Handling error: InvalidClientException, Unauthorized grant type: client_credentials

如何通过邮递员获取访问令牌,就像我通过curl命令获取令牌一样?

3 个答案:

答案 0 :(得分:1)

检查附图,你需要传递如下。

在标题中,您还需要传递Authorization标头。

Authorization - > Basic Y2xpZW50OnNlY3JldA==

enter image description here

这对我有用,我希望这会对你有帮助。

答案 1 :(得分:0)

在curl命令中,您使用的是grant_type = password,但在邮递员请求中,错误说grant_type'client_credentials'无效。

答案 2 :(得分:0)

请参阅随附的屏幕截图。

enter image description here

在正文中,只需选择x-www-form-urlencoded,然后在as键值对中提供grant_type和client_credentials。

相关问题