Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use Google's JavaScript client library to query the Docs API. Although it doesn't come with helpers for Docs specifically, it can still be used with most APIs, including Docs. See this <a href="http://gdatatips.blogspot.com/2008/12/using-javascript-client-library-w-non.html" rel="nofollow noreferrer">blog post</a> by a Google employee that shows a working example. </p> <p>If you end up in an infinite loop of authorizations, see this <a href="http://www.mail-archive.com/google-help-dataapi@googlegroups.com/msg02054.html" rel="nofollow noreferrer">related question</a> from Google groups. Basically, the cookies aren't getting set fast enough, so when the JavaScript client library checks, it finds nothing and redirects to the OAuth authorization page. A solution is to either add a small delay before the check is done, or use a login button that initiates the authorization instead of doing it on page load. </p> <p>You would also need to add any image to your page that resides on the same domain. It can be hidden with CSS, as long as in the DOM.</p> <p>Using the example in the above blog post, I was able to retrieve my documents list with JavaScript alone. Here's the modified initialize function I used to get rid of the infinite authorization loop:</p> <pre><code>function initialize() { var scope = 'http://docs.google.com/feeds/'; if (google.accounts.user.checkLogin(scope)) { var service = new google.gdata.client.GoogleService('writely', 'DocList-App-v1.0'); service.getFeed(scope + 'documents/private/full/', handleFeed, handleError); } else { var loginButton = $("&lt;button&gt;Click here to login&lt;/button&gt;"); loginButton.click(function() { var token = google.accounts.user.login(scope); // can ignore returned token }); $("body").append(loginButton); } }; ​ </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload