Spring 提取访问令牌
我是Spring Boot的新手,我正在尝试编写一个简单的应用程序来了解更多关于OAuth2的信息。我的安全配置是当前的Spring 提取访问令牌,spring,spring-boot,oauth-2.0,Spring,Spring Boot,Oauth 2.0,我是Spring Boot的新手,我正在尝试编写一个简单的应用程序来了解更多关于OAuth2的信息。我的安全配置是当前的 @Override protected void configure(HttpSecurity http) throws Exception { http.oauth2Login().successHandler((request, response, authentication)->{ System.out.prin
@Override
protected void configure(HttpSecurity http) throws Exception {
http.oauth2Login().successHandler((request, response, authentication)->{
System.out.println("Authorities are " + authentication.getAuthorities());
OidcUser user = (OidcUser) authentication.getPrincipal();
System.out.println("attributes are" + user.getAttributes());
redirectStrategy.sendRedirect(request, response, "/");
});
}
是否需要向整个oauth2Login()进程添加钩子来提取访问令牌?OidcUser仅包含idToken。是的,还有另一种提取访问令牌的方法。您可以使用主体提取器,主体提取器是一个接口,可以帮助我们从该令牌本身获取所有详细信息 使用上面的链接了解流程并实现相同的功能