Spring Oauth2错误的自定义渲染
如何更改Spring Oauth2错误的渲染?例如,当您试图访问受保护的rest资源而不提供Spring Oauth2错误的自定义渲染,spring,spring-mvc,spring-boot,spring-security,spring-security-oauth2,Spring,Spring Mvc,Spring Boot,Spring Security,Spring Security Oauth2,如何更改Spring Oauth2错误的渲染?例如,当您试图访问受保护的rest资源而不提供承载头时,Spring Framework会显示此错误: <oauth> <error_description>Full authentication is required to access this resource</error_description> <error>unauthorized</error> </oauth>
承载
头时,Spring Framework会显示此错误:
<oauth>
<error_description>Full authentication is required to access this resource</error_description>
<error>unauthorized</error>
</oauth>
访问此资源需要完全身份验证
未经授权
我希望它能像我用@ControllerAdvice和@ExceptionHandler注释处理的其他API响应和错误消息一样呈现
我曾尝试提供WebResponseExceptionTranslator,但它仅在我提供错误凭据时触发
我看到,DefaultOAuth2ExceptionRenderer
负责呈现此错误,但无法更改它。这有帮助吗?(…accessDeniedHandler(accessDeniedHandler
)以及以下内容: