Here are some notes for the Google Drive API JavaScript Quickstart example at https://developers.google.com/drive/v3/web/quickstart/js.
Running on local host
1. Make sure to copy the full Client ID (everything in the Client ID field) and that the Authorized JavaScript origins is set to "http://localhost:8000".
2. Make sure to replace everything between the 2 quotation marks with your client id.
3. Make sure to run the command "python -m SimpleHTTPServer 8000" in the same folder where the "quickstart.html" is located. Otherwise, there will be file not found error when running "http://localhost:8000/quickstart.html" in the browser.
4. If all goes well, a prompt similar to the one below will appear.
5. After clicking the Authorize button and passing the authorization process, the name and id of the file first 10 files on the Google Drive are displayed. The authentication is valid until the browser data is cleared.
--------------------------------------------------------------------------------------------------------------------------
Running on web server
The web host for this example is "neocities.org" and the domain name used is "http://wei48221.neocities.org/"
1. Create a new API project or modify an existing one that supports Drive API and set the Authorized JavaScript origins to the domain name under which the test file "quickstart.html" is hosted.
2. Upload the test file "quickstart.html" to theweb host.
3. Be sure to replace the Client ID with the one just created in step-1 above.
4. Save the change and load the modified "quickstart.html". Windows similiar to the ones below will appear.
5. After granting access, the name and id of the top 10 files on Google Drive will appear in a window similar to the one below.
Reference:
Below is a more extensive and complete example of how to use JavaScript to access Drive API. Unfortunately, I am not able to to make it work (but I think it could provide some insights into how to use JavaScript to access Drive API).
Google Drive API using Javascript
http://bytutorial.com/tutorials/google-api/introduction-to-google-drive-api-using-javascript
No comments:
Post a Comment