【问题标题】:Postman oAuth2 error Unauthorized grant type邮递员 oAuth2 错误未经授权的授权类型
【发布时间】:2017-02-23 09:38:24
【问题描述】:

我有一个使用 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 命令获取令牌一样?

【问题讨论】:

    标签: java oauth-2.0 postman oauth2


    【解决方案1】:

    检查附图,你需要像下面这样通过。

    并且在标头中您还需要传递授权标头。

    Authorization --> Basic Y2xpZW50OnNlY3JldA==

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

    【讨论】:

    • 感谢您的回答。我已经尝试过您的建议,它也对我有用,但我想使用邮递员的 Authorization OAuth 2.0 来生成标题。可能吗? @Parth Solanki
    • 这正是我一直在寻找的。谢谢
    • @AshishKumarMondal wc
    【解决方案2】:

    请看附上的截图。

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

    【讨论】:

      猜你喜欢
      • 2018-07-01
      • 2019-11-09
      • 1970-01-01
      • 2021-01-24
      • 2021-04-24
      • 2020-09-17
      • 2021-10-01
      • 2021-03-19
      • 2023-03-07
      相关资源
      最近更新 更多