Sean Mackesey
Sean Mackesey

Reputation: 10939

Google Drive API downloadUrl does not work

In order for a podcast client to download the files, it needs a direct download link. The Google Drive API returns two fields in a file's metadata that can play this role:

This issue seems unresolved and suggests this is still broken, but I have a few questions:

Upvotes: 5

Views: 1734

Answers (1)

supersan
supersan

Reputation: 6141

When requesting the file with the downloadUrl you must specify the following authorization in your request header:

"Authorization: Bearer $token"

Where $token is the access_token returned by gapi for the user like this:

gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse().access_token;

So if you were using curl the request would be something like this:

curl -o download -H "Authorization: Bearer $token" $downloadUrl 

Upvotes: 1

Related Questions