簡體   English   中英

錯誤403使用Python將文件上傳到Google文檔

[英]Error 403 uploading a file to Google Docs with Python

嘗試使用Python / gdata-2.0.13將文件上傳到Google文檔時,我遇到403錯誤:

import gdata.docs.data
import gdata.docs.client

client = gdata.docs.client.DocsClient(source="MyUpdater")
client.ClientLogin("mymail@gmail.com", "mykey", client.source);
client.http_client_debug = True

ms = gdata.data.MediaSource(file_path="g:/Python/Utiles/test.doc", content_type="application/msword'")
entry = client.Upload(ms, "Test File")

# Error:
gdata.client.RequestError: Server responded with: 403, <errors xmlns='http://sch
emas.google.com/g/2005'><error><domain>GData</domain><code>ServiceForbiddenExcep
tion</code><internalReason>You do not have permission to perform this operation.
</internalReason></error></errors>
...

我試過下載文件,沒有問題。 我使用的是常規Gmail帳戶(例如,沒有Google Apps或付費帳戶)。

有任何想法嗎? TIA,巴勃羅

import gdata.docs.service
import gdata.docs.data

client = gdata.docs.service.DocsService()
client.ClientLogin("me@gmail.com", 'pass', 'test')

ms = gdata.data.MediaSource(file_path="/home/jake/Desktop/test.txt",
                            content_type=gdata.docs.service.SUPPORTED_FILETYPES['TXT'])
entry = client.Upload(ms, "Test File")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM