使用 Python 将文件上传到 Google 文档时出现错误 403

发布于 2024-10-07 13:47:26 字数 994 浏览 0 评论 0原文

我在尝试将文件上传到 Google 文档时遇到 403 错误 使用Python / gdata-2.0.13:

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

client = gdata.docs.client.DocsClient(source="MyUpdater")
client.ClientLogin("[email protected]", "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, 巴勃罗

I'm having a 403 error when trying to upload a file to Google Docs
with Python / gdata-2.0.13:

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

client = gdata.docs.client.DocsClient(source="MyUpdater")
client.ClientLogin("[email protected]", "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>
...

I tried downloading files, no problem there. I'm using a regular Gmail account (eg, no Google Apps or paid account).

Any ideas?
TIA,
Pablo

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇纵 2024-10-14 13:47:26
import gdata.docs.service
import gdata.docs.data

client = gdata.docs.service.DocsService()
client.ClientLogin("[email protected]", '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")
import gdata.docs.service
import gdata.docs.data

client = gdata.docs.service.DocsService()
client.ClientLogin("[email protected]", '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")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文