As per spec, Google Docs can be downloaded in different formats using the appropriate exportLinks entry in the file metadata obtained using the Drive API. The URLs specified by these entries support CORS, so one can use them from pure Javascript, without a proxy.

This works for most files and document types (doc, presentation) but not spreadsheets. When you try an XHR GET on a spreadsheet exportLinks URL from browser Javascript,

The OPTIONS request returns a valid response, but it has an Expires header of Fri, 01 Jan 1990 00:00:00 GMT

The browser gives up at this point (probably due to the Expires)

Doing a GET with the same Authorization, Referer, Origin headers using curl returns the spreadsheet alright, but the response headers don't contain any Access-Control-Allow-Origin header, so it wouldn't have worked from the browser.

Other document types behave in the expected manner for OPTIONS and GET, returning correct Expires and CORS headers.

In fact, old spreadsheets - those with exportLink URLs which look like https://docs.google.com/feeds/download/spreadsheets/Export?key=XXX&exportFormat=xlsx also work. The problem is confined to new sheets, whose exportLink URLs look like https://docs.google.com/spreadsheets/export?id=XXX&exportFormat=xlsx.

1 Answer
1

It seems to be a known bug when using the Drive API with the new version of Google Sheets (other Google file types and the older version of sheets don't seem to have the issue). Unfortunately, no known workarounds, except "to introduce a server-side component that would download the file and then pass it along to the client."

Thanks. Somehow missed that question. It's a shame that a simple straight-line failure has not been fixed in months, and what's more, doesn't even appear in the list of open issues.
– ganeshvFeb 13 '15 at 4:43

hey @ryanroth, do you know, has this issue been solved?
– Slava32Jun 11 '16 at 21:07