I have an app in GAE (Python 2.7), and now need access to Google Drive to display a (shared) list of folders and documents.
Searching usually results in pointers to DrEdit, including App Engine and Google Drive API, which asks the same question but accepts an answer I don't agree with, as DrEdit is an example app for Google Drive, not GAE.
The files list from the Drive API is what I'd like to be able to use from GAE: https://developers.google.com/drive/v2/reference/files/list
Although Google App Engine and Google Drive are both Google products, unfortunately they are not directly linked. Google Drive APIs can be accessed by the
google-api-python-client
library, which you have to install.The process can be found at Python Google Drive API Quickstart Guide, and the summarized form is as follows:
On Google's side: Allow Drive API Access for your GAE program
client_secret.json
and place it in your root code directory. You will need this to request credentials from users.On your side: Download the
google-api-python-client
library, unzip it in your code directory and runpython setup.py install
. This will install the library which holds many Google product's APIs.Now you are ready to use the Drive API. You can test your access using the sample code. Read it because it's a good guide for writing your own code! If you are accessing user data, you will need to request user credentials when they log in and most probably store them. Then, to use the API, the easiest way would be to get the
service
object:Above code snippet is modified from sample code.
The Reference API for Google Drive can be found here.
The same general procedure is required to link GAE to other Google product's APIs as well e.g. Calendar. All the best writing your program!