1

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?

  • Does this answer your question? https://stackoverflow.com/questions/15202163/get-shared-link-through-google-drive-api – emptyhua Oct 06 '21 at 07:44
  • `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 Oct 06 '21 at 08:57
  • 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 Oct 06 '21 at 18:46
  • Unfortunately, your link was not helpful for me. I need direct link, not webViewLink :( – gogita kupatadze Oct 06 '21 at 20:12
  • @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 Oct 08 '21 at 07:51
  • Because, if you open that webContentLink, you will get 403 error – gogita kupatadze Oct 10 '21 at 00:19
  • Well, I don't get a 403 error, I can download a file I don't have access to if I use the webContentLink retrieved by another account who does have access. Can you provide a set of reproduction steps? – Iamblichus Oct 11 '21 at 07:57
  • I use this code, same as documentation and I get webContentLinks without any problem. Main issue is that, my links are not valid for another users without token. They get 403 error. I can't paste code here, it's too long for comment but it's same as in documentation – gogita kupatadze Oct 11 '21 at 10:47
  • `Main issue is that, my links are not valid for another users without token. They get 403 error.` Sure, but I don't get that 403 error when accessing by other users. That's why I asked for the reproduction steps, which doesn't necessarily mean a huge amount of code (as far as I know, the only code necessary corresponds to calling `Files: get` and getting the `webContentLink` from the response). Also, there's no need (actually not recommended) to post the code in comments; you can edit your question instead. – Iamblichus Oct 12 '21 at 07:11

1 Answers1

0

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.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449