【问题标题】:Gsuite Business - access calendars of usersGsuite Business - 访问用户的日历
【发布时间】:2018-08-02 10:04:31
【问题描述】:

我有一个 Gsuite Business 帐户和多个用户,我希望(在 Python 中)访问所有用户的日历(只读),以在应用程序中显示事件。

作为超级管理员,有没有一种方法可以做到这一点,而无需让每个用户都同意该应用将访问他们的日历?

【问题讨论】:

  • 使用服务帐号并授予其访问用户 gsuite 帐号的权限。
  • 您需要在 gsuite 中查看,否则将无法访问
  • 是的,谢谢,我同时找到了它

标签: python google-calendar-api google-workspace


【解决方案1】:

所以感谢@DaImTo 的评论,创建一个服务帐户确实是要走的路,然后关注https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority 就可以了

from google.oauth2 import service_account
import googleapiclient.discovery

SCOPES = ['https://www.googleapis.com/auth/calendar']
SERVICE_ACCOUNT_FILE = 'GOOGLE_SECRET.json'

credentials = service_account.Credentials.from_service_account_file(
        SERVICE_ACCOUNT_FILE, scopes=SCOPES)

delegated_credentials = credentials.with_subject('address@example.com')

google_calendar = googleapiclient.discovery.build('calendar', 'v3', credentials=delegated_credentials)

events = google_calendar.events().list(
    calendarId='address@example.com',
    maxResults=10
).execute()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-06
    相关资源
    最近更新 更多