security整合oauth2异常总结
异常1:
error="invalid_grant", error_description="A redirect_uri can only be used by implicit or authorization_code grant types."
异常定位:DefaultRedirectResolver
错误信息:是因为我们在设置oauth2授权模式的地方没有按照正确的格式
解决方案:
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
// 从数据库oauth_client_details表读取客户端配置
clients.inMemory().withClient("c1")
.redirectUris("http://www.baidu.com")
.secret(new BCryptPasswordEncoder().encode("123456"))
.autoApprove(true)
// 重点是这个地方,注意格式,一般我们不会犯这个错误,学习的过程中有可能就会导致这个问题
.authorizedGrantTypes("authorization_code,refresh_token");
}