首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gsuite Business -访问用户日历

Gsuite Business -访问用户日历
EN

Stack Overflow用户
提问于 2018-02-22 22:04:52
回答 1查看 66关注 0票数 1

我有一个Gsuite商业帐户和几个用户,我想(在Python中)访问所有用户的日历(只读),以便在应用程序中显示事件。

作为超级管理员,有没有一种方法可以做到这一点,而不必要求每个用户同意应用程序将访问他们的日历?

EN

回答 1

Stack Overflow用户

发布于 2018-02-22 23:52:39

所以多亏了@DaImTo comment,创建一个服务帐户确实是一种方法,然后遵循https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority就可以完成这项工作

代码语言:javascript
复制
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()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48929385

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档