Google 工作应用程序 - 日历 API - 阅读所有组织员工日历

Google Apps for Work - Calendar API - Read All Organisation Employees Calendar

在我们的组织中,我们使用 "Google Apps for Work",我需要定期导出所有员工的日历数据,以便自动统计计算他们在会议上花费的时间。

如果可能的话,你能提示我吗? 目前,the official solution I found 要求每个用户 sign-in 通过 OAuth 授予我的应用程序访问他们日历的权限,而且,授予的凭据将在某个时候过期。

但是我需要达到相同的结果,但是 "back-end service" 具有管理员权限而无需用户登录和应用程序批准,这可能吗? 或者 google 日历即使对于 "Google Apps for Work" 也被认为是私人的东西并且每个用户都需要单独授予权限?

提前致谢! 此致

但是我需要达到相同的结果,但是 "back-end service" 具有管理员权限而无需用户登录和应用程序批准,这可能吗?

您要找的是service accounts。使用服务帐户,您可以代表域中的用户访问数据,该域有时称为 "delegating domain-wide authority"。幸运的是,您可以将其用于 Google Apps for Work。

If you have a Google Apps domain—if you use Google Apps for Work, for example—an administrator of the Google Apps domain can authorize an application to access user data on behalf of users in the Google Apps domain. For example, an application that uses the Google Calendar API to add events to the calendars of all users in a Google Apps domain would use a service account to access the Google Calendar API on behalf of users

这是在 using a P12 file:

时使用 Python 的片段
from oauth2client.service_account import ServiceAccountCredentials

client_email = '123456789000-abc123def456@developer.gserviceaccount.com'
scopes = ['https://www.googleapis.com/auth/sqlservice.admin']

credentials = ServiceAccountCredentials.from_p12_keyfile(
client_email, '/path/to/keyfile.p12', scopes=scopes)

Retrieving all calendar resources

要检索与特定日历关联的资源条目的第一页,请将以正斜杠结尾的 HTTP GET 请求发送到资源供稿 URL。包括授权 header,如身份验证中所述。

GET https://apps-apis.google.com/a/feeds/calendar/resource/2.0/{domain name}/

您可以选择将开始参数中带有空字符串的 HTTP GET 请求发送到资源供稿 URL。

GET https://apps-apis.google.com/a/feeds/calendar/resource/2.0/{domain name}/?start=""