尝试将文件上传到Google文档时遇到403错误 使用Python / gdata-2.0.13:
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, 巴勃罗
答案 0 :(得分:1)
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")