在python web-application中从Google Calendar(version ='v3')获取事件时出错

时间:2013-01-15 08:46:28

标签: events oauth-2.0 google-calendar-api

我正在使用FLOW api通过我的应用程序授权访问Google日历,在Google日历版本'v3'中。

身份验证完美无缺,但当尝试从该人的Google日历中访问该特定人员的事件时,会出现以下错误。

HttpError: <HttpError 404 when requesting https://www.googleapis.com/calendar/v3/calendars/primary/events?alt=json&key='DEVELOPER_KEY' returned "Not Found">

虽然对此很了解但无法解决同样的错误。

我正在使用以下代码段从Google日历中提取事件。

events = service.events().list(calendarId='primary').execute() #fetch out events for first time
while True:
    for event in events.get('items', []):
        print event['summary']
    page_token = events.get('nextPageToken') #check if any event present in next page of the calendar
    if page_token:
        events = service.events().list(calendarId='primary', pageToken=page_token).execute()
    else:
        break

1 个答案:

答案 0 :(得分:0)

将字符串'primary'替换为用户的完整电子邮件地址:

events = service.events().list(calendarId='myuser@gmail.com').execute() #fetch out events for first time
while True:
    for event in events.get('items', []):
        print event['summary']
    page_token = events.get('nextPageToken') #check if any event present in next page of the calendar
    if page_token:
        events = service.events().list(calendarId='primary', pageToken=page_token).execute()
    else:
        break