Python 如何从谷歌应用程序中获取日历列表?

Python 如何从谷歌应用程序中获取日历列表?,python,calendar,google-apps,Python,Calendar,Google Apps,我只想获得日历列表、日历所有者及其忙/闲状态 我已经根据添加了服务帐户,并且我可以从单个用户获得日历。但我想在整个领域内做这件事 f = file('key.p12', 'rb') key = f.read() f.close() credentials = SignedJwtAssertionCredentials('xxx@developer.gserviceaccount.com', key,

我只想获得日历列表、日历所有者及其忙/闲状态

我已经根据添加了服务帐户,并且我可以从单个用户获得日历。但我想在整个领域内做这件事

f = file('key.p12', 'rb')
key = f.read()
f.close()
credentials = SignedJwtAssertionCredentials('xxx@developer.gserviceaccount.com',
                                            key,
                                            scope='https://www.googleapis.com/auth/calendar.readonly',
                                            user_agent='bot',
                                            sub='john@example.cz')    #I want calendars from everyone
http = httplib2.Http()
http = credentials.authorize(http)
service = build('calendar', 'v3', http=http)
lists = service.calendarList().list(pageToken=None).execute(http=http)
pprint.pprint(lists)

您还需要使用Admin SDK中的目录API来根据提取域中所有用户的列表。

Ok,但如果我为每个用户执行此操作,则每个用户需要1秒多一点的时间。如果你的公司有400名员工,完成这项工作需要7分钟。这太过分了。你能不能编辑你的第一篇文章,让我们看看你是如何实现这一点的?每个用户一秒钟的时间似乎太遥远了,因为我从来没有见过超过几个女士。我完全按照第一篇文章中的方式实现了它。唯一的区别是添加了一行,它要求为以前获取的日历列表提供freebusy。因此,只需再提出一个请求/响应。