我有一个使用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命令获取令牌一样,如何通过邮递员获取访问令牌?
最佳答案
检查所附图片,您需要像下面这样通过。
并且在标头中,您还需要传递Authorization标头。Authorization
-> Basic Y2xpZW50OnNlY3JldA==
这对我有用,希望对您有帮助。