0

Basically am facing the same problem as "How do I use exportlinks from javascript to download a Gdoc using Drive SDK?"

So that means I can't do an Ajax call from my website to download a Google Spreadsheet and use it as a database?

I was able to do the same for downloading Images using the downloadUrl from my drive and it works.

Can someone tell me How to do the iframe proxy workaround for the above problem that someone had mentioned in the question I referenced?

$.ajax({url:'https://spreadsheets.google.com/feeds/download/spreadsheets/Export?
      key='+fileid+'&exportFormat=csv&v=3&access_token='+accToken.access_token,
      crossDomain:'true',}).
      done(  function(data){alert(data);});

I get the following error :

XMLHttpRequest cannot load https://spreadsheets.google.com/feeds/download/spreadsheets/Export?      key=ABCDEF&exportFormat=csv&v=3&access_token=acctokenhere. Origin http://mywebsite.in is not allowed by Access-Control-Allow-Origin.
Community
  • 1
  • 1
yeskarthik
  • 60
  • 5

2 Answers2

0

CORS is not yet enabled by Google, so why not proxying the request by your server and served it to your page with Ajax, you will not have an issue with Access-Control-Allow-Origin.

Yacine Rezgui
  • 1,771
  • 1
  • 18
  • 15
  • Yep, I tried exactly the same yesterday and it works perfectly. I wrote a Java service which does the job of fetching the file for me. I sent the access token along with the request. It does face security issues, so I encrypted the message I sent + used a HTTPS connection. – yeskarthik Aug 20 '12 at 07:10
0

Another but restricted solution is to create an application for Google Chrome if your spreadsheet hasn't to be viewed by an anonymous.

With a Google Chrome application, you can override the limits of Access-Control-Allow-Origin by adding url permissions in your manifest.

If you need some help on this subject, I can help you :)

Yacine Rezgui
  • 1,771
  • 1
  • 18
  • 15