Files
google-mcp/gcalendar/__pycache__/calendar_tools.cpython-312.pyc
T

132 lines
17 KiB
Plaintext
Raw Normal View History

Ë
ÐuhY:ãó¦ddlZddlZddlmZmZddlmZddlmZddl m
Z
ddl m Z m
Z
mZddlmZmZmZddlmZd Zd
Zej.ej0¬ «ej2e«Zej8«d ed
efd«Zej8«d ed
efd«Zej8«d eded
efd«Z ej8«d ed
efd«Z!ej8« d d ededeedeede"d
ef d«Z#ej8« d!d edededededeedeedeeedeed
efd«Z$y)"éN)ÚListÚOptional)Ú Credentials)Úbuild)Ú HttpError)Úget_credentialsÚstart_auth_flowÚhandle_auth_callback)Ústart_oauth_flowÚcheck_auth_statusÚstop_oauth_flow)Úserverz1https://www.googleapis.com/auth/calendar.readonlyz/https://www.googleapis.com/auth/calendar.events)ÚlevelÚuser_idÚreturncƒóÌKtjd|«tg} t||«}|S#t$r'}tj d|«d|cYd}~Sd}~wwxYw­w)a“
Start the Google OAuth authentication process with automatic callback handling.
This tool provides a smoother authentication experience by automatically
opening a browser window and handling the callback process.
Args:
user_id: The unique identifier (e.g., email address) for the user.
Returns:
Instructions for completing the authentication.
z-Starting OAuth authentication flow for user: z$Error starting authentication flow: z Failed to start authentication: N)ÚloggerÚinfoÚCALENDAR_READONLY_SCOPEr Ú ExceptionÚerror)rÚscopesÚresultÚes úI/Users/taylorwilsdon/git/google_workspace_mcp/gcalendar/calendar_tools.pyÚ
start_authrslèø€ô ‡K¸yÐ
&€Fð! '¨6Ó2ˆØˆ
øÜ ò Ð;¸A¸3Ð1°!°Ð5ûð6üs0‚ A$£
1°A$± A!ºAÁA!ÁA$ÁA!Á!A$cƒó¼Ktjd|« t|«}|S#t$r'}tj d|«d|cYd}~Sd}~wwxYw­w)
Check the status of an ongoing authentication process.
Args:
user_id: The unique identifier (e.g., email address) for the user.
Returns:
A status message about the authentication process.
z)Checking authentication status for user: z&Error checking authentication status: z'Failed to check authentication status: N)rrr rr)rrrs rÚ auth_statusr3s`èø€ô ‡K;¸G¸" +ˆØˆ
øÜ ò Ð=¸a¸SÐ8¸¸Ð<ûð=üs0Aœ )¨A© A²AÁAÁAÁAÁAÚauthorization_codecƒó´Ktjd|« tg}d}|d|}td|||¬«\}}|j «|j «k7r'tj d|d|«d|d |d
|d Stjd |«d
|S#t $r)}tjd|d¬«d|cYd}~Sd}~wwxYw­w)aG
Completes the OAuth flow by exchanging the authorization code for credentials.
Args:
user_id: The unique identifier (e.g., email address) for the user.
authorization_code: The authorization code received from Google OAuth.
Returns:
A string indicating success or failure.
z0Attempting to complete authentication for user: zhttp://localhost:8080/callbackz?code=úclient_secret.json)Úclient_secrets_pathrÚauthorization_responseÚ redirect_urizUser ID mismatch: provided z, authenticated as zWarning: You authenticated as z , but requested credentials for z. Using authenticated email z for credentials.z0Successfully completed authentication for user: zPAuthentication successful! You can now use the Google Calendar tools with user: z!Error completing authentication: T)Úexc_infoz#Failed to complete authentication: N)rrrr
ÚlowerÚwarningrr)rrrr$Úfull_callback_urlÚ
user_emailÚ credentialsrs rÚ
complete_authr+Hsèø€ô ‡KBÀ7À)Ðð Ø+˜n¨FÐ3EÐ2FÐô#7Ø 4ØØ#4Ø#
ш
 × Ñ Ó  §¡£Ò N‰Nи ÐATÐU_ÐT`Ð 4°Z°LÐ@`ÐahÐ`iðj0Ø0:¨|Ð;LðNð
Oô  ÐFÀzÀlÐaÐblÐamÐnøä ò иÐ<Àtˆ Ô4°Q°CÐ8ûð9üsACœA)B#ÂCÂB#Â"CÂ# CÂ,CÃ
Cà CÃCÃCcƒóbKtjd|«tg}tjd|d|« t ||d¬«}tjd|«|r |js'tjd
|« t||«}|S td
d|¬«}tjd|«|j«j«j«}|jdg«}|syd}|D]%} | jdd«}
| d} |d|
d| dz
}Œ'tjdt|«d|«|j!«S#t
$r'}tj
d|«d|cYd }~Sd }~wwxYw#t
$r'}tj
d |«d |cYd }~Sd }~wwxYw#t"$r+} tj
d|d| «d| dcYd } ~ Sd } ~ wt
$r*}tj%d |d|«d!|cYd }~Sd }~wwxYw­w)"zä
Lists the Google Calendars the user has access to.
Args:
user_id: The unique identifier (e.g., email address) for the user.
Returns:
A string listing the calendars or an authentication prompt.
z'Attempting to list calendars for user: z&Calling get_credentials with user_id: z
, scopes: r!©r"úget_credentials returned: úError getting credentials: úFailed to get credentials: Nú)Missing or invalid credentials for user: úFailed to start auth flow: ú%Failed to start authentication flow: ÚcalendarÚv3©r*ú.Successfully built calendar service for user: Úitemsz/You don't seem to have access to any calendars.z+Here are the calendars you have access to:
Úsummaryz
No SummaryÚidú- ú (ID: ú)
zSuccessfully listed z calendars for user: úAn API error occurred for user ú: zAn API error occurred: ú$. You might need to re-authenticate.z9An unexpected error occurred while listing calendars for úAn unexpected error occurred: )rrrÚdebugrrrÚvalidr'r rÚ calendarListÚlistÚexecuteÚgetÚlenÚstriprÚ exception)
rrr*rrÚserviceÚ
calendar_listr8Úoutputr4r9Úcal_idrs
rÚlist_calendarsrOrsAèø€ô ‡K9¸'¸Ð
&€FÜ
‡L9¸'¸À*ÈVÈHÐ% g¨vÐK_Ô Ü Ð1°+°Ð
˜k×ÐBÀ7À)Ð% g¨vÓ6ˆˆ
˜
 D°kÔÜ ÐDÀWÀIÐ×?ˆ
Ø×! '¨2ÓáØÛˆHØ—l‘l 9¨lÓ;ˆGؘd^ˆ ˜˜7˜) 6¨&¨°Ð 5‰Fðô  Ð*¬3¨u«:¨,Ð6KÈGÈ9Ð|‰|‹~Ðøô= ò Ð2°1°#Ð,¨Q¨CÐ0ûð1ûôò L‰LÐ6°q°cÐ :¸1¸ >ûð ?ûô, òUÜ Ð6°w°i¸rÀ%ÀШÐ/SÐTûÜ ò×ÑÐTÐU\ÐT]Ð]_Ð`aÐ_bШsÐ3ûð4üsº;H/¾&E!Á$&H/Â
FÂH/ÂA&GÄH/ÄAGÅ H/Å! FÅ*F ÆFÆH/Æ FÆH/Æ GÆF?Æ9GÆ:H/Æ?GÇH/Ç H,Ç G6Ç0H,Ç1H/Ç6 H,ÈH'È!H,È"H/È'H,È,H/Ú calendar_idÚtime_minÚtime_maxÚ max_resultscƒóæKtjd|d|«tg} t||d¬«}tj d|«|r |j
s'tj
d|« t||«}|S td d
|¬«} tjd|«|€Itjj«j«dz}
|
}tjd|«| j«j||||dd¬«j!«} | j#dg«} | sd|dSd|d}
| D] }|dj#d|dj#d««}|dj#d|dj#d««}|j#dd«}|d }|j#d!d"«}|
d#|d$|d%z
}
|
d&|d'z
}
|
d(|d'z
}
|
d)|d'z
}
Œ¢tjd*t%| «d+|d|«|
j'«S#t$r'}tjd|«d|cYd }~Sd }~wwxYw#t$r'}tjd
|«d |cYd }~Sd }~wwxYw#t($r+}tjd,|d-|«d.|d/cYd }~Sd }~wt$r*}tj+d0|d1|«d2|cYd }~Sd }~wwxYw­w)3a
Lists events from a specified Google Calendar within a given time range.
Args:
user_id: The unique identifier (e.g., email address) for the user.
calendar_id: The ID of the calendar to fetch events from. Defaults to 'primary'.
time_min: The start time for the event query (RFC3339 format, e.g., '2025-04-27T10:00:00-04:00').
Defaults to the current time if not provided.
time_max: The end time for the event query (RFC3339 format). Optional.
max_results: The maximum number of events to return. Defaults to 25.
Returns:
A string listing the events or an authentication prompt.
z#Attempting to get events for user: ú , calendar: r!r-r.r1r2r3Nr/r0r4r5r6r7ÚZz%Defaulting time_min to current time: TÚ startTime)Ú
calendarIdÚtimeMinÚtimeMaxÚ
maxResultsÚ singleEventsÚorderByr8z&No upcoming events found in calendar 'z'.z+Here are the upcoming events for calendar 'z':
ÚstartÚdateTimeÚdateÚendr9zNo Titler:ÚlocationúN/Ar;r<r=z Start: Ú
z End: z Location: zSuccessfully retrieved z events for user: r>z getting events: z-An API error occurred while fetching events: r@z6An unexpected error occurred while getting events for r?rA)rrrrrBrCr'r rrrÚdatetimeÚutcnowÚ isoformatÚeventsrErFrGrHrIrrJ)rrPrQrRrSrr*rrrKÚnowÚ
events_resultrhrMÚeventr^rar9Úevent_idrbrs rÚ
get_eventsrmªsHèø€ô, ‡K5°g°Y¸lÈ;È-Ð
&€Fð% g¨vÐK_Ô Ü Ð1°+°Ð +×"3Ò"3Ü N‰NÐFÀwÀiÐ 
Cä)¨'°6Ó:Ø
ð #4ð,˜
 D°kÔÜ ÐDÀWÀIÐ Ð Ü×,×8¸>ˆC؈ K‰KиzÐ ŸÓØØØð