Skip to content

Commit

Permalink
When listing calendars, only pull calendars with a minimum access rol…
Browse files Browse the repository at this point in the history
…e of 'writer'. (#326)
  • Loading branch information
MelissaAutumn authored Mar 20, 2024
1 parent 6d9db07 commit c8ff8e4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions backend/src/appointment/controller/apis/google_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging

import requests
from google_auth_oauthlib.flow import Flow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
Expand Down Expand Up @@ -79,10 +78,12 @@ def get_profile(self, token):
return user_info

def list_calendars(self, token):
"""List the calendars a token has access to with the minAccessRole of writer.
Ref: https://developers.google.com/calendar/api/v3/reference/calendarList/list"""
response = {}
items = []
with build("calendar", "v3", credentials=token, cache_discovery=False) as service:
request = service.calendarList().list()
request = service.calendarList().list(minAccessRole='writer')
while request is not None:
try:
response = request.execute()
Expand Down

0 comments on commit c8ff8e4

Please sign in to comment.