小编pak*_*kkk的帖子

使用OAuth2从Spring Security自定义身份验证错误

我想知道是否可以自定义以下授权错误:

{
  "error": "unauthorized",
  "error_description": "Full authentication is required to access this resource"
}
Run Code Online (Sandbox Code Playgroud)

当用户请求没有权限时,我得到了它。我想将其自定义为与Spring Boot错误非常相似:

{
 "timestamp":1445441285803,
 "status":401,
 "error":"Unauthorized",
 "message":"Bad credentials",
 "path":"/oauth/token"
}
Run Code Online (Sandbox Code Playgroud)

有可能吗

非常感谢。

java security spring-security spring-boot spring-security-oauth2

8
推荐指数
2
解决办法
4828
查看次数