![](/img/trans.png)
[英]Useing python to download a file in google drive that is created by a google app script
[英]File does not appear in Google Drive - Google docs created with Python
下面顯示的代碼運行良好。 我看到文件正在我的 Jupiter 筆記本中創建,因此該腳本似乎有效。 唯一的問題是,該文件沒有出現在我的雲端硬盤中。
creds_1 = ServiceAccountCredentials.from_json_keyfile_name("creds_1.json", scope)
service = build('docs', 'v1', credentials=creds_1)
title = 'My Document'
body = {
"body": {},
"title": "My document2"
}
doc = service.documents().create(body=body).execute()
print('Created document with title: {0}'.format(doc.get('title')))
這是因為服務帳戶有自己的驅動器,所以您不會將其上傳到您的個人驅動器。 服務帳戶與您的用戶是分開的。
一個選項是在您的雲端硬盤中創建一個文件夾,與服務帳戶共享它並讓代碼將文件上傳到那里。
如果您是G Suite 用戶,另一種方法是將服務帳戶配置為使用域范圍委派來模擬您的用戶,並將文件直接上傳到您的雲端硬盤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.