[英]"error": "invalid_grant", "error_description": "Bad credentials"
I'm implementing Oauth2 in SpringBoot RestFul API.我正在 SpringBoot RestFul API 中实现Oauth2 。 Everything is working fine except when I use the wrong password getting error response:一切正常,除非我使用错误的密码获得错误响应:
Status : 400Bad Request状态:400Bad 请求
{
"error": "invalid_grant",
"error_description": "Bad credentials"
}
But I'm excepting like this:但我是这样的例外:
Status : 401 Unauthorized状态:401 未经授权
{
"error": "unauthorized",
"error_description": "Invalid username/password combination"
}
A 401 status would be returned if your authorization credentials are incorrect.如果您的授权凭据不正确,将返回401状态。 This would be your basic auth username and password (in Postman Authorization tab), which appears were unchanged.这将是您的基本身份验证用户名和密码(在 Postman Authorization 选项卡中),看起来没有改变。
A 400 status is returned because the validation of the request's body parameters (username, password) fails to find a match.由于请求的正文参数(用户名、密码)的验证未能找到匹配项,因此返回 400 状态。 (ie. Bad credentials were supplied.) It's like other requests where a required parameter is not submitted or formatted correctly. (即,提供了错误的凭据。)就像其他请求一样,所需的参数未提交或格式不正确。 Your request passes the oauth server's basic authorization for the login endpoint.您的请求通过了 oauth 服务器对登录端点的基本授权。 It would be confusing and incorrect if both scenarios returned a 401 status.如果这两种情况都返回 401 状态,那将是令人困惑和不正确的。400 status400 状态
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.