Download Google Drive file via AJAX ignoring CORS

Hi folks

I have a csv file in Google Drive which I wanted to use from my JavaScript site.

If you copy share link from Google Drive you’ll get something like

Which is interactive url. So we need to get a download link

It can be done via

And then we get a link

But when you try to get it via AJAX

var xhr = new XMLHttpRequest();'GET', '');
Failed to load Redirect from '' to '*/1_cG2NrtGfuHv_aQGOHWOAZx7wapBlEah?e=download' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://my-server-url' is therefore not allowed access.

Not good. I spent a lot of time and finally found

Prepend this magic url with my url and the problem solved

...'GET', '');


Stay tuned


About mnaoumov

Senior .NET Developer in Readify
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s