Magog
Magog

Reputation: 505

Google drive and authorized HTTP GET for downloading a file

I develop application for Google Drive. I have problem with downloading files. Official doc describes this process with next words: "To download a file's content, send an authorized HTTP GET request to the file's downloadUrl.". The main problem is in "authorized HTTP GET request". I've used:

And none of these have helped me. If I try to download file it opens browser for authorization in the very first time. Can you help me download file without usermade authorization?

Upvotes: 1

Views: 3973

Answers (1)

Alain
Alain

Reputation: 6034

To download the file's content, you will need to use an OAuth 2.0 access token in an authorized HTTP request such as:

GET <dowloadUrl>
Authorization: Bearer <ACCESS_TOKEN>

You can try this with curl by using a command such as:

curl <downloadUrl> -H 'Authorization: Bearer <ACCESS_TOKEN>'

If you want to be able to download the file from a web browser using cookie authentication (using the cookies of the currently logged-in user), you should use the webContentLink instead.

Upvotes: 2

Related Questions