1

The python sample source code goes thru the details of authentication/etc. I am looking for a simple upload to the Google Drive folder that has public writable permissions. (Plan to implement authorization at a later point).

I want to replace the below code to upload file to Google Drive folder instead.

f = open('output.txt')
for line in allLines:
       f.write (line)
f.close()

(If it makes any difference, I plan to run this thru Google App Engine).

Thanks.

user1055761
  • 1,071
  • 1
  • 12
  • 28
  • And its even the first sentence of the api doc ;) – jdi Jul 08 '12 at 23:50
  • Thanks Wooble! The document also states that it is possible to get long-lived tokens, which I am assuming will allow to do batch'ed uploads, without going thru a UI or user-interaction. – user1055761 Jul 09 '12 at 00:50
  • @Wooble: Can you make this an answer to the question? It'll help to mark it as answered. – schuppe Jul 09 '12 at 16:06
  • Wooble, do you still want me to do this ? Btw, I have posted [another related question](http://stackoverflow.com/questions/11432742/replace-openssl-in-oauth2client-crypt-to-work-with-pycrypto) in line with being able to get the Cert/(server-to-server) based Oauth2.0 to work on app-engine.. – user1055761 Jul 12 '12 at 11:46

2 Answers2

1

You can't. All requests to the Drive API need authentication (source: http://developers.google.com/drive/about_auth)

Wooble
  • 87,717
  • 12
  • 108
  • 131
  • Current Python samples for Google Drive Access, are thru the Drive SDK and are assuming a UI based interaction. I am looking to use OAuth 2.0 via a certificate-based authentication for server-to-server interactions. So something like for [task](http://code.google.com/p/google-api-python-client/source/browse/samples/service_account/tasks.py) that wraps google drive service. Thanks. (Shall I post this as a separate question ?) – user1055761 Jul 09 '12 at 21:41
  • Could I use 'build("drive", "v1", http=http)' in the [task example](http://code.google.com/p/google-api-python-client/source/browse/samples/service_account/tasks.py) in place of 'service = build("tasks", "v1", http=http)' ? Thanks. – user1055761 Jul 09 '12 at 22:14
0

As Wooble said, you cannot do this without authentication. You can use this service + file-upload widget to let your website visitors upload files to your Google Drive folder: https://github.com/cloudwok/file-upload-embed/

Markus Klems
  • 474
  • 2
  • 6