From fddb6277dcbd994eaa808ebc7191216a08eb146d Mon Sep 17 00:00:00 2001 From: sooyoungh Date: Thu, 28 Dec 2023 15:45:34 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EC=8B=A4=ED=8C=A8=20=EC=8B=9C=20log=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/dearsanta/app/security/JwtInterceptor.java | 2 +- .../dearsanta/app/security/KakaoOauthClient.java | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/dearsanta/app/security/JwtInterceptor.java b/src/main/java/com/dearsanta/app/security/JwtInterceptor.java index bfae798..c18940e 100644 --- a/src/main/java/com/dearsanta/app/security/JwtInterceptor.java +++ b/src/main/java/com/dearsanta/app/security/JwtInterceptor.java @@ -22,7 +22,7 @@ public class JwtInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - + log.info("JwtInterceptor - preHandle(): 로그인 시도"); String accessToken = request.getHeader("Authorization"); String memberId = getMemberIdByAccessToken(accessToken); diff --git a/src/main/java/com/dearsanta/app/security/KakaoOauthClient.java b/src/main/java/com/dearsanta/app/security/KakaoOauthClient.java index 41a4970..686cb1a 100644 --- a/src/main/java/com/dearsanta/app/security/KakaoOauthClient.java +++ b/src/main/java/com/dearsanta/app/security/KakaoOauthClient.java @@ -12,6 +12,8 @@ import org.springframework.stereotype.Service; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.HttpServerErrorException; import org.springframework.web.client.RestTemplate; import java.util.NoSuchElementException; @@ -60,7 +62,17 @@ private KakaoOauthTokenDto getKakaoAccessTokenByAuthorazationCode(String authori body.add("code", authorizeCode); HttpEntity request = new HttpEntity<>(body, headers); - return restTemplate.postForObject(TOKEN_URI, request, KakaoOauthTokenDto.class); + KakaoOauthTokenDto kakaoOauthTokenDto = null; + try { + kakaoOauthTokenDto = restTemplate.postForEntity(TOKEN_URI, request, KakaoOauthTokenDto.class).getBody(); + } catch(HttpClientErrorException e) { + log.error("HttpClientErrorException : " + e.getResponseBodyAsString()); + } catch(HttpServerErrorException e) { + log.error("HttpServerErrorException : " + e.getResponseBodyAsString()); + } catch(Exception e) { + log.error("Exception : " + e); + } + return kakaoOauthTokenDto; } // 2. 토큰으로 사용자 정보 조회하기