[Internal] GSF: How to interface with Google Drive from GSF
Anonym
Description:
This article provides information about how one can use Google Drive to interface with GSF.
Solution:
One possible solution is to use create a custom request handler handler and route mapper that use the Google Drive API to retrieve data. To do this, you can use the procedure below:
1) Register an API application and receive security credentials from Google using the information described on the following page:
https://developers.google.com/identity/protocols/OAuth2
You can register the application using the following link:
https://console.developers.google.com/
2) To register the application use the steps below:
- Create a new project
- Enable the google drive api
- Click on credentials
- Select "Create credentials" > "OAuth client ID"
- Select "Web application"
- Enter "localhost:9191" under "Authorized JavaScript origins"
- Click create
- You will be give the CLIENT_ID. You should download the JSON file that Google provides for your records.
3) Follow the instructions in the "Create a WebApp Request Handler" section of the following GSF tutorial:
https://www.harrisgeospatial.com/docs/webapp-all.html
Skip the "Create a Bounding Box Task" section and create the "html" directory discussed in the "Create a WebApp Map Client" section.
4) Instead of creating the "index.html", "style.css", "GSFutils.js" and "app.js" files mentioned in the "Create a WebApp Map Client" section of the tutorial, simply create a file called "index.html" and then copy the example code google provides in on the following page:
https://developers.google.com/drive/v3/web/quickstart/js
Within this code, modify the line that says "var CLIENT_ID = '
'" by replacing '' with the client ID provided by google in step 2.
5) Save everything, restart GSF and then go to http://localhost:9191/webapp. I was then able to log into by google account and view my files meta data.
If you want to do more with Google Drive APIs, you will need to study the Google Drive REST API:
https://developers.google.com/drive/v2/reference/
Written by DS 6/16/2017