diff --git a/src/main/java/nutshell/server/service/googleCalendar/GoogleCalendarService.java b/src/main/java/nutshell/server/service/googleCalendar/GoogleCalendarService.java index 4685d25..687a0f0 100644 --- a/src/main/java/nutshell/server/service/googleCalendar/GoogleCalendarService.java +++ b/src/main/java/nutshell/server/service/googleCalendar/GoogleCalendarService.java @@ -81,7 +81,6 @@ public GoogleCalendar register(final String code, final Long userId) { GoogleCalendar.builder() .user(user) .email(data.email()) - .serialId(data.sub()) .accessToken(tokens.accessToken()) .refreshToken(tokens.refreshToken()) .build() @@ -92,7 +91,12 @@ public GoogleCalendar register(final String code, final Long userId) { public void unlink(final Long userId, final Long googleCalenderId){ User user = userRetriever.findByUserId(userId); GoogleCalendar googleCalendar = googleCalendarRetriever.findByIdAndUser(googleCalenderId, user); - googleService.unlink(googleCalendar.getAccessToken()); + try { + googleService.unlink(googleCalendar.getAccessToken()); + } catch (Exception e) { + reissue(googleCalendar); + googleService.unlink(googleCalendar.getAccessToken()); + } googleCalendarRemover.remove(googleCalendar); } @@ -110,12 +114,12 @@ public List getGoogleCalendars( googleCalender -> { try { schedules.addAll(getEvents(googleCalender, startDate, range, categoriesDto)); - } catch (IOException e) { + } catch (Exception e) { reissue(googleCalender); try { schedules.addAll(getEvents(googleCalender, startDate, range, categoriesDto)); - } catch (IOException ioException) { - log.error("Google Calender Error : {}", ioException.getMessage()); + } catch (Exception ex) { + log.error("Google Calender Error : {}", ex.getMessage()); } } } @@ -134,12 +138,12 @@ public GoogleCategoriesDto getCategories( googleCalender -> { try { categories.addAll(getCategories(googleCalender)); - } catch (IOException e) { + } catch (Exception e) { reissue(googleCalender); try { categories.addAll(getCategories(googleCalender)); - } catch (IOException ioException) { - log.error("Google Calender Error : {}", ioException.getMessage()); + } catch (Exception ex) { + log.error("Google Calender Error : {}", ex.getMessage()); } } }