我有一个Gsuite商业帐户和几个用户,我想(在Python中)访问所有用户的日历(只读),以便在应用程序中显示事件。
作为超级管理员,有没有一种方法可以做到这一点,而不必要求每个用户同意应用程序将访问他们的日历?
发布于 2018-02-22 23:52:39
所以多亏了@DaImTo comment,创建一个服务帐户确实是一种方法,然后遵循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()https://stackoverflow.com/questions/48929385
复制相似问题