0

How can I change the render of Spring Oauth2 errors? For example when you try to access rest resource which is protected without providing Bearer header, this error is rendered by Spring Framework :

<oauth>
<error_description>Full authentication is required to access this resource</error_description>
<error>unauthorized</error>
</oauth>

I want it to render like my other API responses and error messages which I am handling with @ControllerAdvice and @ExceptionHandler annotations.

I have tried to provide WebResponseExceptionTranslator but it only triggers when I provide bad credentials.

I see that the DefaultOAuth2ExceptionRenderer is responsible for rendering this errors, but could not manage to change it.

Saša Šijak
  • 8,717
  • 5
  • 47
  • 82
  • does this helps ? http://stackoverflow.com/questions/30262600/customize-oauth2-error-response-on-client-authentication-with-spring-security (`...accessDeniedHandler(accessDeniedHandler`) – alexbt Dec 31 '16 at 15:13
  • and this: https://github.com/spring-projects/spring-security-oauth/issues/691 – alexbt Dec 31 '16 at 15:15

0 Answers0