gpt4 book ai didi

java - Spring OAuth2.0 : Where does spring store the access token?

转载 作者:太空宇宙 更新时间:2023-11-04 12:15:19 25 4
gpt4 key购买 nike

我正在使用 Spring Oauth2.0,并使用 Google 作为授权提供商。我的 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

这是我的主课

@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();
}

}

此后,我需要访问 google api 来获取一些用户信息,但这需要访问 token 。 Spring 在哪里存储这个 token ?我怎样才能取回它?预先感谢!

最佳答案

您可以看到this有关 Spring 和社交登录的文档,那么当您获得更多经验时,可以尝试将身份验证微服务存储在 Redis 上。我在 Outlook 中使用网关模式,并且必须在客户端配置中指定一个 url,oauth 服务器将在其中检索 token 和请求中指定的一些数据。

希望对您有所帮助。

关于java - Spring OAuth2.0 : Where does spring store the access token?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39476200/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com