diff --git a/src/main/java/com/numberone/backend/domain/token/service/TokenService.java b/src/main/java/com/numberone/backend/domain/token/service/TokenService.java index 9b96da67..27df3ff8 100644 --- a/src/main/java/com/numberone/backend/domain/token/service/TokenService.java +++ b/src/main/java/com/numberone/backend/domain/token/service/TokenService.java @@ -44,8 +44,10 @@ public GetTokenResponse loginKakao(GetTokenRequest tokenRequest) { try { ResponseEntity response = restTemplate.exchange(kakaoProperties.getUser_api_url(), HttpMethod.GET, new HttpEntity<>(null, headers), KakaoInfoResponse.class); String email = response.getBody().getKakao_account().getEmail(); - String realName = Optional.ofNullable(response.getBody().getKakao_account().getProfile().getNickname()) - .orElse("사용자"); + String realName = "실명을 가져올 수 없습니다."; + if(response.getBody().getKakao_account().getProfile() != null){ + realName = response.getBody().getKakao_account().getProfile().getNickname(); + } return getTokenResponse(email, realName); } catch (Exception e) { throw new BadRequestSocialTokenException(); @@ -63,7 +65,7 @@ public GetTokenResponse loginNaver(GetTokenRequest tokenRequest) { String email = response.getBody().getResponse().getEmail(); String realName = Optional.ofNullable(response.getBody().getResponse().getName()) - .orElse("사용자"); + .orElse("실명을 가져올 수 없습니다."); return getTokenResponse(email, realName); } catch (Exception e) { throw new BadRequestSocialTokenException();