Skip to content

Commit

Permalink
chore: 카카오 요청 실패 시 log 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sooyoungh committed Dec 28, 2023
1 parent 9da36d4 commit fddb627
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
14 changes: 13 additions & 1 deletion src/main/java/com/dearsanta/app/security/KakaoOauthClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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. 토큰으로 사용자 정보 조회하기
Expand Down

0 comments on commit fddb627

Please sign in to comment.