Spring boot oauth2 研究第N天 action 2

来源:互联网 发布:klairs淘宝官网 编辑:程序博客网 时间:2024/05/21 17:09

http://localhost:8080/yuyu/oauth/token?grant_type=client_credentials&client_id=trusted-app&client_secret=secret&response_type=code&scope=read&redirect_uri=/resources/user&t=111


感谢上苍,终于解决了

error="invalid_client", error_description="Bad client credentials"

No client with requested id: normal-app

下面是我的搜索之路

1,当然是搜索验证不过

oauth2.0 authorize

没找到,跟源码,找到是这个类,继续搜

AuthorizationEndpoint

这个类是这里产生的

DefaultOAuth2RequestFactory

还是不行,换个思路

oauth2.0 注册 clientId

不行,继续乱搜,其实这里已经接近了,因为就是找到一篇http://blog.csdn.net/buyaore_wo/article/details/48680981,意识到是configure(ClientDetailsServiceConfigurer clients) 这里的问题,http://www.leftso.com/blog/139.html给的源码并没有解决,所以将代码拷贝过来:

@PostConstruct
public void init() {
InMemoryClientDetailsServiceBuilder inMemoryClientDetailsServiceBuilder = new InMemoryClientDetailsServiceBuilder();
// @formatter:off
inMemoryClientDetailsServiceBuilder.

InMemoryClientDetailsService

AuthorizationEndpoint

... 省略

但是还是不起作用,哎,毕竟不熟,继续搜

authorizationserverconfigureradapter 不起作用

WebSecurityConfigurerAdapter AuthorizationServerConfigurerAdapter

authorizationEndpoint

getOAuth2RequestFactory

最后继续跟源码,发现我的低级错误。在

public void configure(ClientDetailsServiceConfigurer clients) throws Exception {

的方法里调用

clients.inMemory().clients(yuyuClientDetailsService);  

并没有设置值进去,修改为

clients.withClientDetails(yuyuClientDetailsService);

搞定,眼泪。。。



原创粉丝点击