I am trying to get a simple Python Google Drive uploader working. I've created a project in the developer console, enabled the Drive API and added an OAuth 2.0 client ID (application type Other).
I can see the application listed in the Google Drive's Settings -> Manage Apps, and can successfully execute many operations provided by the Python Drive API client from Google. files ().insert () however fails with:
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart&convert=false&useContentAsIndexableText=false&alt=json returned "Insufficient Permission">
This is for an insert into a directory which I have made writable to everyone, as seen below:
credentials = get_credentials ()
http = credentials.authorize (httplib2.Http ())
service = discovery.build ('drive', 'v2', http=http)
PARENT_ID="0B1gLgXwTiUzlfmo0UGVsZ1NWdW1nZG9OcENNYkJua2E1d0pqWE14TjFyc2hVMHdEU1h5czQ"
perms = service.permissions().list(fileId=PARENT_ID).execute()
print ("PERMISSIONS:")
for perm in perms["items"]:
for p in perm:
print (p, perm[p])
print
parent = {
"isRoot": False,
"kind": "drive#parentReference",
"id": PARENT_ID
}
service.files ().insert (
body = {"parents" : [parent]},
media_body='./test.txt',
convert=False,
useContentAsIndexableText=False
).execute ()
Which lists the permission as:
(u'withLink', True)
(u'kind', u'drive#permission')
(u'etag', u'"F-w0rsCIWtQP8RGyv_V1DlKfcRk/icwHkDdfUYuMzqZrUsVIyvu85K8"')
(u'role', u'writer')
(u'type', u'anyone')
(u'id', u'anyoneWithLink')
(u'selfLink', u'https://www.googleapis.com/drive/v2/files/0B1gLgXwTiUzlfmo0UGVsZ1NWdW1nZG9OcENNYkJua2E1d0pqWE14TjFyc2hVMHdEU1h5czQ/permissions/anyoneWithLink')
Can anyone point me to which permission I am missing, please?