Fail to download file using Google Document List + oAuth REST protocol

Cheok Yan Cheng picture Cheok Yan Cheng · Jun 14, 2012 · Viewed 7.8k times · Source

By using the following tool oAuth Playground, and following the documentation Google Documents List API version 3.0. Here is what I had done.

  1. I get access token for the following 3 scopes. https://docs.google.com/feeds/ https://docs.googleusercontent.com/ https://spreadsheets.google.com/feeds/. Please refer to the following attachment.

    enter image description here

  2. After getting access token and refresh token, I begin to make query, to get the download URL for a particular document. I made the following GET request https://docs.google.com/feeds/default/private/full/?v=3. The respond is something more or less like


<entry ...
    ...
    <content type='application/zip' src='https://doc-0s-84-docs.googleusercontent.com/docs/securesc/4t...626&amp;e=download&amp;gd=true'/>
    ...
</entry>
  1. I then key in the download URL https://doc-0s-84-docs.googleusercontent.com/docs/securesc/4t...626&amp;e=download&amp;gd=true. The result looks like this.

enter image description here

However, I am getting the following respond.

HTTP/1.1 302 Found
Status: 302
Content-length: 0
Via: HTTP/1.1 GWA
Set-cookie: AUTH_98m5tbqk1ftn500bl9bsjcrv52agg3u2_nonce=mupodp3rtqnoc; Domain=doc-0s-84-docs.googleusercontent.com; Expires=Thu, 14-Jun-2012 08:33:15 GMT; Path=/docs/securesc/4t66vjvgb1974sathdoeioitbft52pel; Secure; HttpOnly
Expires: Thu, 14 Jun 2012 08:23:15 GMT
X-google-cache-control: remote-fetch
Server: HTTP Upload Server Built on Jun 7 2012 12:49:38 (1339098578)
Location: https://docs.google.com/nonceSigner?nonce=mupodp3rtqnoc&continue=https://doc-0s-84-docs.googleusercontent.com/docs/securesc/4t66vjvgb1974sathdoeioitbft52pel/kea7kv7gjen26s72ovuvc0lc9to7ogf7/1339660800000/06447459084918146340/06447459084918146340/0B3MN1kmYytfaNWIwMzYzYzYtNmUxNS00OWMzLThkYzctZmUyNjg5MTY2NmUw?amp;gd%3Dtrue%26amp;e%3Ddownload%26h%3D16653014193614665626&hash=rtv0rrnj8bal21va48shlckqbjf5gjhm
Cache-control: private, max-age=0
Date: Thu, 14 Jun 2012 08:23:15 GMT
P3p: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
Content-type: text/html; charset=UTF-8

I get the same result, even though I append ?v=3 at the back of URL which makes it looks like https://doc-0s-84-docs.googleusercontent.com/docs/securesc/4t...626&amp;e=download&amp;gd=true?v=3

Any idea on why I am getting such error?

Answer

Tim picture Tim · Jun 22, 2012

The URL you are using is URL encoded. Simply change &amp;e=download&amp;gd=true to &e=download&gd=true in the URL.