@@ -5,6 +5,7 @@ import com.google.api.services.calendar.Calendar
55import com.google.api.services.calendar.model.Event
66import com.google.auth.http.HttpCredentialsAdapter
77import com.google.auth.oauth2.UserCredentials
8+ import org.slf4j.LoggerFactory
89import org.springframework.beans.factory.annotation.Value
910import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties
1011import org.springframework.cache.annotation.Cacheable
@@ -25,6 +26,8 @@ class GoogleCalendarsClient(
2526 @Value(" \$ {trainer-advisor.integrations.google-calendar.root-url}" ) private val googleCalendarRootUri : URI
2627) {
2728
29+ private val log = LoggerFactory .getLogger(javaClass)
30+
2831 private val servicesCache = mutableMapOf<GoogleAccount , Calendar >()
2932 .withDefault { createCalendarService(it) }
3033
@@ -37,6 +40,8 @@ class GoogleCalendarsClient(
3740 calendarSettings : GoogleCalendarSettings ,
3841 interval : Interval <ZonedDateTime >
3942 ): List <GoogleCalendarItem <ZonedDateTime >> {
43+ log.info(" Fetching events in {} for calendar {} using {}" , interval, calendarSettings.calendarId, account)
44+
4045 val service = servicesCache.getValue(account)
4146 val events =
4247 service.events().list(calendarSettings.calendarId)
@@ -77,6 +82,7 @@ class GoogleCalendarsClient(
7782 therapist : TherapistRef ,
7883 account : GoogleAccount
7984 ): List <GoogleCalendar > {
85+ log.info(" Fetching calendars for therapist {} using {}" , therapist, account)
8086 val service = servicesCache.getValue(account)
8187
8288 return service.CalendarList ().list()
@@ -89,7 +95,7 @@ class GoogleCalendarsClient(
8995 val credentials = UserCredentials .newBuilder()
9096 .setClientId(googleOAuthProps.registration[" google" ]!! .clientId)
9197 .setClientSecret(googleOAuthProps.registration[" google" ]!! .clientSecret)
92- .setRefreshToken(account.refreshToken)
98+ .setRefreshToken(String ( account.refreshToken) )
9399 .setTokenServerUri(tokenUri)
94100 .build()
95101
0 commit comments