简体   繁体   English

Spring OAuth2.0:spring存储访问令牌的位置是什么?

[英]Spring OAuth2.0: Where does spring store the access token?

I am using Spring Oauth2.0 using Google as authorization provider. 我使用Spring Oauth2.0作为授权提供商使用Google。 I have the following configuration in my application.yml file 我的application.yml文件中有以下配置

security:
  oauth2:
    client:
      clientId: xxxxxxxxxxxxxxxxxxxx
      clientSecret: xxxxxxxxxxxxxxxxxx
      accessTokenUri: https://accounts.google.com/o/oauth2/token
      userAuthorizationUri: https://accounts.google.com/o/oauth2/auth
      authenticationScheme: query
      clientAuthenticationScheme: query
      scope: https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/userinfo.profile
    resource:
      userInfoUri: https://www.googleapis.com/oauth2/v3/userinfo
      preferTokenInfo: false

And this is my main class 这是我的主要课程

@SpringBootApplication
@EnableOAuth2Sso
public class App 
{
    public static void main(String[] args) throws Exception {
        SpringApplication.run(App.class, args);    
    }

    @Bean public RequestContextListener requestContextListener(){
        return new RequestContextListener();
    }

}

After this I need to access google api to get some user info but that requires an access token. 在此之后,我需要访问谷歌API以获取一些用户信息,但这需要访问令牌。 Where does Spring store this token? Spring存储此令牌的位置在哪里? How can I retrieve it? 我怎样才能找回它? Thanks in advance !! 提前致谢 !!

You can see this documentation about Spring and social login, then when you get more experience could try to put an auth micro service that store your tokens on redis. 你可以看到这个关于Spring和社会的登录文件,那么当你获得更多的经验可以尝试把你的令牌存储在Redis的一个auth微服务。 I use a gateway pattern with Outlook and have to specify a url in the client configuration where the oauth server will retrieve the token and some data specified in the request. 我在Outlook中使用网关模式,并且必须在客户端配置中指定一个URL,其中oauth服务器将检索令牌和请求中指定的一些数据。

I hope it helps. 我希望它有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM