2017-09-09 26 views
1

1.春のセキュリティoauth2依存性を使用しています.Googleへの認証に成功しましたが、リフレッシュトークンを取得できません。OAuth2ClientAuthenticationProcessingFilterを使用した春のブートによるGoogle Oauth2ログイン

WebSecurityConfigurerアダプタで

2.

private OAuth2ClientAuthenticationProcessingFilter filter() { 
     // Creating the filter for "/google/login" url 
     OAuth2ClientAuthenticationProcessingFilter oAuth2Filter = new 
       OAuth2ClientAuthenticationProcessingFilter(
       "/google/login"); 
     authorizationCodeResourceDetails.setPreEstablishedRedirectUri("http://localhost:8080/"); 
     List<String> scopes = authorizationCodeResourceDetails.getScope(); 
     authorizationCodeResourceDetails.setGrantType("authorization_code"); 


     // Creating the rest template for getting connected with OAuth service. 
     // The configuration parameters will inject while creating the bean. 
     OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(authorizationCodeResourceDetails, 
       oauth2ClientContext); 


     oAuth2Filter.setRestTemplate(oAuth2RestTemplate); 


     // setting the token service. It will help for getting the token and 
     // user details from the OAuth Service 
     String userInfo = resourceServerProperties.getUserInfoUri(); 
     String clientId = resourceServerProperties.getClientId(); 

     UserInfoTokenServices tokenService = new UserInfoTokenServices(resourceServerProperties.getUserInfoUri(), 
       resourceServerProperties.getClientId()); 
     // tokenService.setTokenType(DefaultOAuth2AccessToken.REFRESH_TOKEN); 


     oAuth2Filter.setTokenServices(tokenService); 
//  oAuth2Filter.setTokenServices(defaultToken()); 


     return oAuth2Filter; 
    } 
+0

私が知る限り、OAuth2仕様では、リフレッシュトークンを戻すためにアクセストークンを使用して別のリクエストを行う必要があると言われています。 – tsolakp

+0

@tsolakpコメントありがとうございます。Googleに更新トークンの新しいリクエストを送信するにはどうすればよいですか? –

答えて

0

私は、GoogleのURLのparam requriments、春ブーツapplication.yml社会的な認証設定を追加しました。

関連する問題