Search code examples
google-apigoogle-drive-apigoogle-oauthhttp-live-streaming

How to download drive files through HTTP requests with the access_token included in the url?


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?


Solution

  • 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.