Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 提取访问令牌_Spring_Spring Boot_Oauth 2.0 - Fatal编程技术网

Spring 提取访问令牌

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

我是Spring Boot的新手,我正在尝试编写一个简单的应用程序来了解更多关于OAuth2的信息。我的安全配置是当前的

@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。

是的,还有另一种提取访问令牌的方法。您可以使用主体提取器,主体提取器是一个接口,可以帮助我们从该令牌本身获取所有详细信息

使用上面的链接了解流程并实现相同的功能