繁体   English   中英

Google Drive API:如何从Google Drive下载文件?

[英]Google Drive API:How to download files from google drive?

access_token = ''
import json
r = session.request('get', 'https://www.googleapis.com/drive/v3/files?access_token=%s' % access_token)
response_text = str(r.content, encoding='utf-8')
files_list = json.loads(response_text).get('files')
files_id_list = []
for item in files_list:
    files_id_list.append(item.get('id'))

for item in files_id_list:
    file_r = session.request('get', 'https://www.googleapis.com/drive/v3/files/%s?alt=media&access_token=%s' % (item, access_token))
    print(file_r.content)

我使用上面的代码,谷歌显示: 我们很抱歉……但是您的计算机或网络可能正在发送自动查询。 为了保护我们的用户,我们现在无法处理您的请求。 不知道这个方法是不是原来下载不了,或者问题出在哪里?

您收到此错误的原因是您在循环中请求数据。 导致对谷歌服务器的大量请求。

因此出现错误很抱歉……但是您的计算机或网络可能正在发送自动查询

access_token 不应该放在请求体中,我们应该把 access_token 放在 header 中。可以在这个站点上尝试oauthplayground

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM