oauth2-demo icon indicating copy to clipboard operation
oauth2-demo copied to clipboard

authorization_code模式 获取access_token之后,如何去请求资源?

Open pepsiyoung opened this issue 6 years ago • 5 comments

authorization_code模式 获取access_token之后如何去请求资源服务器, access_token在哪里传,我直接用get获取不了?

pepsiyoung avatar Jun 26 '18 06:06 pepsiyoung

这个作者没有写。其实还是要有一个验证token然后获得请求资源的方法

zx8329200 avatar Jun 27 '18 07:06 zx8329200

@zx8329200 找了很久没找到适用的,能否提供下代码

pepsiyoung avatar Jul 02 '18 12:07 pepsiyoung

@zx8329200 这个怎么写?网上有大概的例子么?找了好多都无效啊

shancg avatar Jul 11 '18 01:07 shancg

SecurityConfiguration 类 void configure(HttpSecurity http)方法 改为以下就可以了 http .requestMatchers() .antMatchers("/oauth/","/login/","/logout/") .and() .authorizeRequests() .antMatchers("/oauth/").authenticated() .and() .formLogin().loginPage("/login") .and() .httpBasic().disable() .csrf() // 不需要被csrf过滤的请求 .requireCsrfProtectionMatcher(new AntPathRequestMatcher("/oauth/authorize")) .disable();

pepsiyoung avatar Jul 15 '18 13:07 pepsiyoung

@pozhenzi9010 @zx8329200 @shancg 授权码模式demo已更新,pull 之后重新看下吧

lexburner avatar Jul 16 '18 03:07 lexburner