diff --git a/src/main/java/com/hlab/yanalyst/domain/upload/YoutubeOAuthService.java b/src/main/java/com/hlab/yanalyst/domain/upload/YoutubeOAuthService.java index dd1bd99..cbede1d 100644 --- a/src/main/java/com/hlab/yanalyst/domain/upload/YoutubeOAuthService.java +++ b/src/main/java/com/hlab/yanalyst/domain/upload/YoutubeOAuthService.java @@ -183,7 +183,16 @@ public class YoutubeOAuthService { form.add("grant_type", "refresh_token"); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - JsonNode token = readJson(restTemplate.postForObject(TOKEN_URL, new HttpEntity<>(form, headers), String.class)); + String response; + try { + response = restTemplate.postForObject(TOKEN_URL, new HttpEntity<>(form, headers), String.class); + } catch (HttpStatusCodeException e) { + if (e.getStatusCode().value() == 400 || e.getStatusCode().value() == 401) { + throw new IllegalStateException("YouTube 채널 연결이 만료되었습니다. 채널을 다시 연결해 주세요.", e); + } + throw new IllegalStateException("YouTube 인증 정보를 갱신하지 못했습니다.", e); + } + JsonNode token = readJson(response); return requiredText(token, "access_token", "YouTube access token을 갱신하지 못했습니다."); } diff --git a/src/main/resources/templates/my_channel.html b/src/main/resources/templates/my_channel.html index daa22ae..4d632ec 100644 --- a/src/main/resources/templates/my_channel.html +++ b/src/main/resources/templates/my_channel.html @@ -45,6 +45,7 @@ +