【发布时间】:2020-05-24 04:32:53
【问题描述】:
我一直在尝试为我的 api 创建一个access_token。我有followed the setup 并且正在使用 Postman 来测试/创建令牌。我似乎无法通过 invalid_grant 错误。
我已经尝试了似乎我能够找到的所有组合,但没有任何运气。这是我的设置:
发送POST 请求至:http://mywebsite.local/oauth/token
在正文中,我将 form-data 设置为此(名称/值):
grant_type password
client_id 1
client_secret <super_long_string>
username my@email.com
password secret
我使用 tinker 创建了一个虚拟用户:
factory('App\User')->create()
我在上面的用户名/密码中使用了新创建的用户。
无论我在做什么(没有通过任何东西),这都是我经常看到的错误:
{
"error": "invalid_grant",
"error_description": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.",
"hint": "",
"message": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."
}
我读过很多次这意味着我试图获得的grant_type 与客户不匹配。我正在使用php artisan passport:client --password 创建客户端,所以我不明白为什么它无效。我只有一个客户,所以我知道我使用的是正确的id。 This issue 好像是一样的东西,我看到了,但已经关闭了。
对于我的标头,我只设置Content-Type application/json,我没有为授权标头设置任何内容。
我不确定还可以尝试什么。感谢您的任何建议!
【问题讨论】:
标签: laravel laravel-passport laravel-6