Python Google Calendar API v3 does not return the "summary" field when listing event items -
i have python script going run cron operation. needs find list of events current day, , perform other action depending on event. far, able make request calendar api, , getting list of events current day. when loop through list of event items, "summary" key item missing. need field can determine event for.
the data in each event item coming no "summary" key
{ "status": "confirmed", "kind": "calendar#event", "end": { "date": "2017-07-29" }, "icaluid": "0000000000000@google.com", "updated": "2017-06-20t00:00:00.000z", "start": { "date": "2017-07-24" }, "etag": "\"0000000000000000\"", "id": "0000000000000" } in google docs found here https://developers.google.com/google-apps/calendar/v3/reference/events#resource shows "summary" key should returned event.
since script going run automatically, setup google service account authorize request api user doesn't have authorize manually. here sample of script i'm using
# -*- coding: utf-8 -*- oauth2client.service_account import serviceaccountcredentials httplib2 import http apiclient.discovery import build import datetime try: scopes = ['https://www.googleapis.com/auth/calendar'] credentials = serviceaccountcredentials.from_json_keyfile_name( '/path/to/credentials/filename.json', scopes=scopes) http_auth = credentials.authorize(http()) starttime = str(datetime.datetime.now().date()) + 't00:00:00-07:00' endtime = str(datetime.datetime.now().date()) + 't23:59:00-07:00' calendar = build('calendar', 'v3', http=http_auth) calid = 'calendar_id_string' response = calendar.events().list(calendarid=calid, timemin=starttime, timemax=endtime).execute() items = response.get('items',[]) item in items: summary = item.get('summary','') # summary blank!! except exception, ex: print ex thank help
the reason why event "summary" not returned client because of calendar permission set email account.
the email account came credentials json file created when made service account.
when calendar shared email account, permission set "see free/busy (hide details)" instead of "see event details" admin.
with "see free/busy (hide details)" permission, user can see if calendar free or busy @ given time, no event details returned.
by changing permission "see event details" of event details returned client, including "summary" key need.
see here more details:
https://developers.google.com/google-apps/calendar/concepts/sharing https://developers.google.com/api-client-library/python/auth/service-accounts
only calendar owner can change permissions on calendar. if owner then,
log google calendar
click on settings gear button
click settings > calendars > [your calendar name] > share calendar
find email account , change permission setting
click save
otherwise, need contact owner changing permission.
Comments
Post a Comment