1
我使用Spring Oauth2.0
,使用Google作为授权提供者。我有以下的配置,我application.yml
文件Spring OAuth2.0:spring在哪里存储访问令牌?
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();
}
}
这个我需要访问谷歌的API来得到一些用户信息后,但是这需要一个访问令牌。 Spring存储这个令牌的地方在哪里?我如何检索它?提前致谢 !!
你应该有一个类来配置OAuth2,然后你可以定义一个可以在内存或数据库上的tokenStore。 –
查看'TokenStore' http://docs.spring.io/spring-security/oauth/apidocs/org/springframework/security/oauth2/provider/token/TokenStore.html –
有用的链接[如何获取访问令牌](http://stackoverflow.com/questions/23759529/android-how-to-get-google-plus-access-token) –