PabloG
PabloG

Reputation: 26725

Error 403 uploading a file to Google Docs with Python

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

Upvotes: 3

Views: 1220

Answers (1)

Jake
Jake

Reputation: 2625

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")

Upvotes: 1

Related Questions