【发布时间】:2020-04-01 10:36:22
【问题描述】:
我将 Laravel 6 护照 grant password 用于我的 Vue 后端。
当我向 oauth/token 发送正确的凭据时,它可以工作并返回令牌,但是当我发送错误(电子邮件/密码)时,它会返回 400 而不是 401 并显示此消息。
{
"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."
}
我检查了 client_id 和 client_secret。
我用新安装的 Laravel + passport 测试,没有一行代码,Laravel 5.8 返回 401 没有任何问题,但 Laravel 6 返回 400 错误请求。
你有什么想法吗?
【问题讨论】:
-
401 未经授权,不是“错误的凭据”
-
我知道,但是在 Laravel 5.8 中,当我提供错误的用户名/密码时,它会返回 401 并显示以下消息:invalid_credentials(用户凭据不正确),但在 Laravel 6 中,它会返回 400 并显示 invalid_grant 消息 @AlbertoSinigaglia
-
您是否使用 artisan 中的
--password标志创建了您的客户端对? -
根据 Laravel 网站“如果您已经运行了 passport:install 命令,则不需要运行此命令”,但是是的,我删除了它们并使用 --password 标志创建了新客户端。 @mdexp
-
我也遇到了同样的问题,你找到解决办法了吗?
标签: laravel oauth-2.0 laravel-passport laravel-6