1
votes

I use Google Drive to store my files there, but I need to get direct download links for users who are not authorized via API, like Get Link feature in Google Drive for everyone.

webContentLink doesn't work without access_token, it gives me 403 error. is there any other way? Like maybe do "Get Link" feature by API and get link, which will work for everyone with this link?

1
Does this answer your question? stackoverflow.com/questions/15202163/… - emptyhua
webContentLink doesn't work without access_token, it gives me 403 error what do you mean here? How are you trying to retrieve webContentLink? Are you trying to access the file link via Drive API without going through authorization? The link can be shared after it has been retrieved from the API by an authorized user, but it cannot be retrieved by an unauthorized user via API. - Iamblichus
I get webContentLink with my app, which has access. It's authorized, but I want to get webContentLink from my app and send this link to someone, who must not know access_token. - gogita kupatadze
Unfortunately, your link was not helpful for me. I need direct link, not webViewLink :( - gogita kupatadze
@gogitakupatadze but I want to get webContentLink from my app and send this link to someone, who must not know access_token What's stopping you from doing this? Why you cannot send the webContentLink after you've retrieved it? - Iamblichus

1 Answers

0
votes

A file resource has two link properties which can be returned

  • webContentLink A link for downloading the content of the file in a browser. This is only available for files with binary content in Google Drive.

  • webViewLink A link for opening the file in a relevant Google editor or viewer in a browser.

The difference is only the type of file if its a Google drive type file then it can be owned in the Google drive web application. If not then you get a download link.

Both of these links will require that anyone using said links must have permissions on the file at very lest to view them.

Neither of these links should be confused with the sharable link which can be requested from the Google drive web application which will work for anyone that the link is shared with.

enter image description here

there is no way to get a link from the Google drive api that can be shared with a user who does not have access to the file.

There was a time I believe when the webContentlink worked for anyone if the file was set to public that is no longer the case.