Google drive direct link

2019-02-09 20:43发布

问题:

Is there some kind direct links for google drive files, so I could download them by their links? Even temporary links would have been enough.

As I understood, webContentLink can be used only by browsers, downloadUrl can be used for small text files and shoud be used with something like XMLHttpRequest or something else.

回答1:

webContentLink and downloadUrl are the two main links you may use to download a Drive file.

  • downloadUrl requires you to authorize using OAuth 2.0 (append the access token to the URL using downloadUrl + "&access_token=" + access_token or using the Authorization HTTP header). It can be used to download files of Any size. Not sure what made you believe it's only for small text files. It's not. The downloadUrl is a temporary URL that is valid around 24h.
  • webContentLink requires the user to be signed in a Google Account. Basically, it uses cookie authorization which is why we usually say it's to be used in a browser. However there is another interesting use-case for that link: If your file is shared publicly then this link does not require any kind of authorization whereas downloadUrl still needs you to use an OAuth 2.0 access token. The webContentLink never expires.