python - Python 谷歌驱动 API
问题描述
您好,我想使用 OAuth 3.0 Playground 将图像上传到 Google Drive。它有效,但每 3600 秒访问令牌就会更改一次。有谁知道更新令牌的方法,甚至是完全不同的方法。我还需要驱动器中的图像 ID,直到现在我使用返回函数。
headers = {"Authorization": "Bearer ###Acesstoken from Playground###"}
para = {
"name": "" + str(img_counter) + ".png", #file name to be uploaded
"parents": ["###Folder id###"]
}
files = {
'data': ('metadata', json.dumps(para), 'application/json; charset=UTF-8'),
'file': open("./Test.png", "rb")
}
r = requests.post(
"https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart",
headers=headers,
files=files
)
return(r.text)
解决方案
推荐阅读
- telethon - telethon如何使用登录代码请求呼叫
- java - 与以前的版本不同,android studio 版本 4 会自动选择通过 USB 或 android 模拟器在我连接的手机上运行我的应用程序
- pandas - 如何从一列包含嵌套字典的csv创建熊猫数据框?
- nginx - NGINX Ingress controller returning 502 with no logs in backend application pod
- android - PendingIntent from Notifications are not coming back to service. Showing java.lang.NullPointerException
- node.js - 基于其他模型自动更新 MongoDB 模型
- find - 移动文件和复制子树
- wordpress - WC 费用 API 后计算运费
- assembly - 一个简单的 hello world shellcode 中的分段错误?
- c# - 如何使用用户输入名称创建文件?