최종 변경 : 2024.01.22
@Service
public class CustomOAuth2UserService extends DefaultOAuth2UserService {
//DefaultOAuth2UserService OAuth2UserService의 구현체
@Override
public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException {
OAuth2User oAuth2User = super.loadUser(userRequest);
System.out.println(oAuth2User.getAttributes());
String registrationId = userRequest.getClientRegistration().getRegistrationId();
OAuth2Response oAuth2Response = null;
if (registrationId.equals("naver")) {
oAuth2Response = new NaverResponse(oAuth2User.getAttributes());
}
else if (registrationId.equals("google")) {
oAuth2Response = new GoogleReponse(oAuth2User.getAttributes());
}
else {
return null;
}
//추후 작성
}
}
{
resultcode=00, message=success, response={id=123123123, name=개발자유미}
}
{
resultcode=00, message=success, id=123123123, name=개발자유미
}