我使用这个google calendar api代码来开发(你可以找到代码 here ):
from __future__ import print_function
import datetime
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
# If modifying these scopes, delete the file token.json.
SCOPES = 'https://www.googleapis.com/auth/calendar.readonly'
def main():
"""Shows basic usage of the Google Calendar API.
Prints the start and name of the next 10 events on the user's calendar.
"""
# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
store = file.Storage('token.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('./credentials.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('calendar', 'v3', http=creds.authorize(Http()))
# Call the Calendar API
now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time
print('Getting the upcoming 10 events')
events_result = service.events().list(calendarId='primary', timeMin=now,
maxResults=10, singleEvents=True,
orderBy='startTime').execute()
events_result = service.events().list(calendarId='primary',timeMin=now,).execute()
events = events_result.get('items', [])
if not events:
print('No upcoming events found.')
for event in events:
start = event['start'].get('dateTime', event['start'].get('date'))
print(start, event['summary'])
if __name__ == '__main__':
main()
当我使用日历API进行开发时,第一次点击页面的权限按钮时,pycharm控制台可以返回输出。
是否有一个管理员帐户可以控制100人以上的帐户?比如我们公司有100人,如果我想获取100人的数据,是否需要获取100人的账户信息(Gmail账户和密码)和credentials.json文件?
当我第一次为每个人的credentials.json 文件运行代码时,我需要为 100 个人点击 100 次“承认”,这不太好。我希望有管理员权限来简化这个操作。
是否有一个管理员帐户可以控制这100个人?我需要下载 100 个人的 credential.json 文件吗?
我应该点击哪一个进行下一步,如何获取每个人的json文件?
最佳答案
是的,这就是 G Suite Domain-Wide Delegation 。直接来自链接的指南:
In enterprise applications you may want to programmatically access a user's data without any manual authorization on their part. In G Suite domains, the domain administrator can grant third-party applications with domain-wide access to its users' data — this is referred as domain-wide delegation of authority. To delegate authority this way, domain administrators can use service accounts with OAuth 2.0.
关于python - 是否有可用于 google calendar api 的管理员帐户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54084789/