我使用這個谷歌日歷 api 代碼來開發(你可以在這里找到代碼):from __future__ import print_functionimport datetimefrom googleapiclient.discovery import buildfrom httplib2 import Httpfrom 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 個人的憑據.json 文件嗎?下一步應該點擊哪個,如何獲取大家的json文件?
3 回答

倚天杖
TA貢獻1828條經驗 獲得超3個贊
是的,這稱為G Suite 域范圍委派。直接從鏈接的指南:
在企業應用程序中,您可能希望以編程方式訪問用戶的數據,而無需他們進行任何手動授權。在 G Suite 域中,域管理員可以授予第三方應用對其用戶數據的全域訪問權限——這稱為全域授權。為了以這種方式委派權限,域管理員可以使用 OAuth 2.0 的服務帳戶。
添加回答
舉報
0/150
提交
取消