Postman oAuth2 错误未授权授权类型

Postman oAuth2 error Unauthorized grant type

我有一个使用 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 命令获取令牌一样通过邮递员获取访问令牌?

查看附件图片,您需要像下面这样通过。

并且在header中你还需要通过授权header。

Authorization --> Basic Y2xpZW50OnNlY3JldA==

这对我有用,希望对您有所帮助。

请参阅附件中的屏幕截图。

在正文中,只需 select x-www-form-urlencoded 然后在作为键值对中提供 grant_type 和 client_credentials。