How do I open a file in google drive using its api? - javascript

I'm trying to display a text file from google drive in a textarea.
From what I understand there is no direct way to do it; you have to download it using xhr request. I have tried the code that google provide in their documentation [https://developers.google.com/drive/v2/reference/files/get][1] but with no success.
The Error I'm getting is "500 (Internal Server Error)"
The code is the exact the same as in the google's example. Can someone help me with this problem?

Are you making sure you have an access token before sending the request? And are you using the example JavaScript provided?
Authorizing Your App with Google Drive:
All requests to the Google Drive API must be authorized by an authenticated user.

Related

Sending HTTP request from Google Apps Script to a website which uses Google sign-in

I'm looking to use UrlFetchApp from a code in Google Apps Script to send HTTP requests (GET & POST) to a website which uses Google sign-on. And the Google account is same as that used by the Google apps script.
Is this possible? If yes, how safe is it? Does the website get to see my Google account credentials?
Thanks in advance!

Server-side flow for Google Drive API authorization of a javascript Chrome extension

I was reading #Nivco answer to Authorization of Google Drive using JavaScript and saw:
"...all you have to do it is use server-side code to process the authorization code returned after the Drive server-side flow (you need to exchange it for an access token and a refresh token). That way, only on the first flow will the user be prompted for authorization. After the first time you exchange the authorization code, the auth page will be bypassed automatically.
Server side samples to do this is available in our documentation."
Having read the documentation I am still pretty confused about how to process the authorization code and ultimately pass the access and refresh tokens to my Chrome extension so that it can proceed without the server for future requests. Can someone provide an example of the server-side code to do this?
As background I have a Chrome Extension with several thousand users that is built on the Google DocList API but I am trying to transition to the Drive API since the other one is being deprecated. Ideally my code would be entirely stand alone as an extension but I'm willing to accept the single authorization request through my server that Nivco's answer requires.
Thanks!
We've just ported our JavaScript application from using server to client flow. We've removed the server part entirely, it's not needed any longer.
You can see the source code that we used online, it's available uncompressed.

Configuring Google Drive API and SDK

I'm attempting to install the DrEdit sample app for Salesforce onto GAE. The app runs, but saving or opening a file results in an HTTP 403 "Access Not Configured Error".
I have also attempted to use the values for API Access>Client ID for web applications. The Google Drive SDK> OAuth Client ID has also been set variously to the Drive SDK and web app Client IDs.
but, After enabling both (Api, SDK) in Api access service i am still getting same error.
Please see duplicate post about this: Google Drive HTTP 403 “Access Not Configured” error
Copy of the answer given:
Can you make sure that you register your application on the Google APIs Console and enable the Drive API and SDK for it first?
It's all described here: https://developers.google.com/drive/register
Then make sure that you use your Client ID and Client Secret in DrEdit's configuration file.

Google Drive HTTP 403 “Access Not Configured” error

I'm attempting to install the DrEdit sample app for Salesforce onto GAE. The app runs, but saving or opening a file results in an HTTP 403 "Access Not Configured Error".
I have also attempted to use the values for API Access>Client ID for web applications. The Google Drive SDK> OAuth Client ID has also been set variously to the Drive SDK and web app Client IDs. but, After enabling both (Api, SDK) in Api access service i am still getting same error.
Can you make sure that you register your application on the Google APIs Console and enable the Drive API and SDK for it first?
It's all described here: https://developers.google.com/drive/register
Then make sure that you use your Client ID and Client Secret in DrEdit's configuration file.

google gadget and sites api

I'm writing a google gadget (nothing but plain html + javascript) to upload a file onto a private google site using the sites api. http://code.google.com/apis/sites/docs/1.0/developers_guide_protocol.html#UploadingFiles
I can only upload the file using a multi-part form. But it doesn't work because the api needs oauth authentication. Authetication involves setting some header fields in the POST request. Unfortunately form submit does not let us set the header, thus no authentication. I can't make an ajax call because of cross-domain restrictions. Any ideas on what can be done?
One way I can think of is to use a proxy which makes the authenticated call, but I want to avoid that. I need a javascript-only way of doing it.
post to a server side script and initiate a curl request with all the headers you want?
I'm looking at the same problem. I now found Google APIs Client Library for JavaScript. I don't know if it supports Google Sites, but I plan to try.

Categories

Resources