In addition to @DaveSyer answer , which should work for most cases. Sometimes based on configuration and configuration, the above method may not work if FrameworkEndpointHandlerMapping from Spring Security OAuth package is in a higher order than RequestMappingHandlerMapping your application. If so, the servlet manager will never reach your match and will always display the default page.
One way to fix this is to change the display order, given that FrameworkEndpointHandlerMapping order Order.LOWEST_PRECEDENCE - 2 .
Another way is to set the approval page to your own URL rather than being displayed using FrameworkEndpointHandlerMapping , so the servlet manager will reach your application mapping
@Configuration @EnableAuthorizationServer protected static class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter { @Autowired private AuthorizationEndpoint authorizationEndpoint; @PostConstruct public void init() { authorizationEndpoint.setUserApprovalPage("forward:/oauth/custom_confirm_access"); authorizationEndpoint.setErrorPage("forward:/oauth/custom_error"); } }
With this configuration, the displays /oauth/custom_confirm_access and /oauth/custom_error will be used as a confirmation page and an error page, respectively.
source share