def get_drive_service():
'''
Returns an object used to interact with the Google Drive API.
'''
flow = client.flow_from_clientsecrets(
get_credentials_path('secret.json'),
'https://www.googleapis.com/auth/drive')
flow.user_agent = USER_AGENT_NAME
store = Storage(get_credentials_path('storage.dat', False))
credentials = store.get()
if not credentials or credentials.invalid:
flags = tools.argparser.parse_args(args=[])
credentials = tools.run_flow(flow, store, flags)
http = credentials.authorize(httplib2.Http())
service = discovery.build('drive', 'v3', http=http)
return service
评论列表
文章目录