详情:
{"error":"method_not_allowed","error_description":"Request method 'GET' not supported"}
环境:
spring-security-oauth2
原因:
http://127.0.0.1:8003/oauth/token?grant_type=authorization_code&client_id=client1&client_secret=client1-secret&code=cdUQJG&redirect_uri=http://www.baidu.com
默认只支持post
如此:
- 可以使用post请求访问;
- 修改默认方式,如下:
@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);
}
//...
}