0

Can someone please help me on finding a way to send an HTTP request to Google Drive to download a file with the access token included in the url?

I searched a lot in the internet and found only this way to send an access_token in URL: "https://www.googleapis.com/drive/v3/files/[fileID]?access_token=ya29.a0AfH6SMA4FU********&key=[apiKey]"

As you know, it only returns the metadata of the file because it does not contain alt=media. If you add "alt=meida" to the url, it fails to load and returns nothing.

It can be easily fixed with passing the access_token as a header. However, I cannot do that because I am using the url as a "src" of HTML and as a source for video segments in .m3u8 file.

Any suggestion?

ZyadOmer999
  • 117
  • 1
  • 10
  • Is the resource public or private? – Alessandro Sep 02 '20 at 10:29
  • I tried it with both public and private but all failed – ZyadOmer999 Sep 02 '20 at 10:43
  • In this case there is an already accepted answer for public files here: https://stackoverflow.com/a/48133859/7453656 . For private files it's impossible without using OAuth2. – Alessandro Sep 02 '20 at 11:15
  • Does this answer your question? [How to download a Google Drive url via curl or wget](https://stackoverflow.com/questions/48133080/how-to-download-a-google-drive-url-via-curl-or-wget) – Alessandro Sep 02 '20 at 11:16

1 Answers1

1

Since January 1st, 2020, the Google Drive API doesn't support the access_token query parameter anymore.
See https://cloud.google.com/blog/products/application-development/upcoming-changes-to-the-google-drive-api-and-google-picker-api for the announcement.
This change only applies to requests with ?alt=media by the way. Unfortunately that's precisely the kind of requests that you're using...
I'm afraid there's no solution in your case.

Damiano
  • 56
  • 1
  • 5