繁体   English   中英

Google日历错误权限不足

[英]Google calendar error Insufficient Permission

我使用此代码测试Google日历api,当我使用calendarId='primary' ,没有错误。

但是当我使用calendarId='uf0udovlhgel0u7a1ifs69o2u8@group.calendar.google.com'

我的pycharm控制台中的错误消息是:

gleapiclient.errors.HttpError:https://www.googleapis.com/calendar/v3/calendars/uf0udovlhgel0u7a1ifs69o2u8%40group.calendar.google.com/events?maxResults=10&singleEvents=true&orderBy=startTime&alt=json返回“权限不足”

实际上,我有此日历ID,您可以在此图片中看到它: 在此处输入图片说明

这是我的代码:

from __future__ import print_function
import datetime
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools

# If modifying these scopes, delete the file token.json.
# SCOPES = 'https://www.googleapis.com/auth/calendar.readonly'
SCOPES = 'https://www.googleapis.com/auth/calendar'

def main():
    """Shows basic usage of the Google Calendar API.
    Prints the start and name of the next 10 events on the user's calendar.
    """
    # The file token.json stores the user's access and refresh tokens, and is
    # created automatically when the authorization flow completes for the first
    # time.
    store = file.Storage('token.json')
    creds = store.get()
    if not creds or creds.invalid:
        flow = client.flow_from_clientsecrets('./credentials.json', SCOPES)
        creds = tools.run_flow(flow, store)
    service = build('calendar', 'v3', http=creds.authorize(Http()))

    # Call the Calendar API
    now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time
    print('Getting the upcoming 10 events')
    # events_result = service.events().list(calendarId='primary',
    #                                       maxResults=10, singleEvents=True,
    #                                       orderBy='startTime').execute()
    events_result = service.events().list(calendarId='uf0udovlhgel0u7a1ifs69o2u8@group.calendar.google.com',
                                        maxResults=10, singleEvents=True,
                                        orderBy='startTime').execute()
    events = events_result.get('items', [])
    if not events:
        print('No upcoming events found.')
    for event in events:
        start = event['start'].get('dateTime', event['start'].get('date'))
        print(start, event['summary'])


if __name__ == '__main__':
    main()

当我在pycharm控制台中单击链接时,错误是:

 {
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
 }
}

如何解决此错误?

我知道哪里出了错,我的python文件位于文件夹A ,文件夹A没有文件credentials.json

所以有错误。

这是一个非常愚蠢的错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM