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) –