I am facing HTTP 405 error for oauth/token on tomcat 8(linux), while other POST requests are working fine.
Above issue not appears on windows localhost tomcat 8.
Any clues ??
Thanks
I had the same issue, it turned out to be caused by a controller method which I used to map all endpoints to something else ie:
@GetMapping("**")
Resolved the issue with changing the all-matching endpoint to:
@GetMapping("/dev/**")
My Problem got solved after adding the dependency below:
@Bean
public FrameworkEndpointHandlerMapping endpointHandlerMapping() {
return new FrameworkEndpointHandlerMapping();
}
The TokenEndpoint bean has a list of allowed HttpMethods. The default is now just HttpMethod.POST. Somehow calling the setAllowedRequestMethods after the TokenEndpoint bean has been created will fix this. I did this to fix it in a project:
@Configuration
public class OAuth2ProviderTokenGetAllowedBackwardsCompatible implements InitializingBean
{
@Autowired
private TokenEndpoint tokenEndpoint;
@Override
public void afterPropertiesSet() {
tokenEndpoint.setAllowedRequestMethods(new HashSet<HttpMethod>() {{
add(HttpMethod.GET);
add(HttpMethod.POST);
}});
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.