oauth2(spring security)报错method_not_allowed(Request method 'GET' not supported)解决方法

Posted 噢咦嗒的博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oauth2(spring security)报错method_not_allowed(Request method 'GET' not supported)解决方法相关的知识,希望对你有一定的参考价值。

报错信息

<MethodNotAllowed>
<error>method_not_allowed</error>
<error_description>Request method &#39;GET&#39; not supported</error_description>
</MethodNotAllowed>

39是单引号

原因

默认只支持post

解决方法

  1. 下载安装postman工具(或其他post工具)
    使用post调用

  2. 代码增加get的方法

@Configuration
public class OAuthSecurityConfig extends AuthorizationServerConfigurerAdapter {
...
    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
        ...
        endpoints.allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST);// add get method
        ...

        endpoints.tokenServices(tokenServices);
    }
...
}

参考资料

stackoverflow
csdn blog

以上是关于oauth2(spring security)报错method_not_allowed(Request method 'GET' not supported)解决方法的主要内容,如果未能解决你的问题,请参考以下文章

Spring Security Oauth2

Spring-Security OAuth2 设置 - 无法找到 oauth2 命名空间处理程序

Spring Security OAuth2 v5:NoSuchBeanDefinitionException:'org.springframework.security.oauth2.jwt.Jwt

如何使用spring-security,oauth2调整实体的正确登录?

针对授权标头的Spring Security OAuth2 CORS问题

Spring Security---Oauth2详解