【发布时间】:2018-03-24 15:12:14
【问题描述】:
我已成功完成本教程。 https://spring.io/guides/tutorials/spring-boot-oauth2/#_social_login_authserver
但是,我似乎无法将其用作休息后端服务。我总是从授权服务器获取登录页面。
我怎样才能让它工作?
我在帖子中使用以下标题。
Authorization: Bearer <my access token from facebook>
Content-type: application/x-www-form-urlencoded
客户端/资源服务器如下所示:
@EnableAutoConfiguration
@Configuration
@EnableOAuth2Sso
@RestController
public class ClientApplication extends WebSecurityConfigurerAdapter {
@RequestMapping("/")
public String home(Principal user) {
return "Hello " + user.getName();
}
public static void main(String[] args) {
new SpringApplicationBuilder(ClientApplication.class)
.properties("spring.config.name=client").run(args);
}
@Override
public void configure(HttpSecurity http) throws Exception {
http.antMatcher("/**").authorizeRequests().anyRequest().authenticated().and().exceptionHandling().and().csrf().disable();
}
}
【问题讨论】:
标签: spring spring-boot spring-security spring-security-oauth2