How to have multiple scopes with Google Calendar + Google Drive

情到浓时终转凉″ 提交于 2019-12-05 23:18:20

When you authenticate simply add both scopes. The user will be prompted to grant you access to both.

SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly https://www.googleapis.com/auth/calendar'

You may have to put a comma between them I a not sure it depends upon the library

Now I am not a python dev, however most of the Google client libraries are created the same. Assuming you are using that you will need to create both a calendar service and a drive service. You create them both using the same credential you got from above. Code ripped from here.

serviceDrive = discovery.build('drive', 'v3', http=http)
serviceCal = discovery.build('calendar', 'v3', http=http)

When you need to access calendar you use the calendar service when you need to access drive you use the drive service.

Add scopes into a list object.

Example:

SCOPES = ['https://www.googleapis.com/auth/calendar',
          'https://www.googleapis.com/auth/drive.metadata.readonly']
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!