谷歌日历错误权限不足

2024-04-25 16:55:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我用这段代码测试googlecalendarapi,当我使用calendarId='primary'时,没有错误。你知道吗

但是当我使用calendarId='uf0udovlhgel0u7a1ifs69o2u8@group.calendar.google.com'时。你知道吗

my 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 returned "Insufficient Permission">

事实上,我有这个日历ID,你可以在这张图片中看到: enter image description here

这是我的密码:

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."
 }
}

如何修复此错误?你知道吗


Tags: thefromhttpsimportcomjson错误google
1条回答
网友
1楼 · 发布于 2024-04-25 16:55:10

我知道哪里错了,我的python文件在文件夹A,文件夹A没有文件credentials.json。你知道吗

所以有错误。你知道吗

这是一个非常愚蠢的错误。你知道吗

相关问题 更多 >