1
1. 봄 보안 oauth2 의존성을 사용합니다. Google에 성공적인 인증을 받았지만 새로 고침 토큰을 가져올 수 없습니다. 새로 고침 토큰을 가져 오려면 어떻게해야합니까? PrincapalUser 객체에서 액세스 토큰 만 가져올 수 있습니다. OAuth2ClientAuthenticationProcessingFilter를 사용하여 봄 부팅으로 Google Oauth2 로그인
에서 내가 구글의 URL을 param requriments, 사회적 인증 구성 application.yml 스프링 부팅을 추가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;
}
OAuth2 스펙에 따르면 새로 고침 토큰을 다시 가져 오기 위해 액세스 토큰을 사용하여 다른 요청을해야한다고 나와 있습니다. – tsolakp
@tsolakp 의견을 보내 주셔서 감사합니다. Google에 새로 고침 토큰을 새로 요청하려면 어떻게해야합니까? –