Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get shared link through Google Drive API

Tags:

I am working on an app using Google Drive. I want the user to be able to share files by link, setting the permissions to anyone and withLink as described in the Google Developers documentation.

However, I cannot figure out what link to share. When I share a file in the Google Drive browser interface, I see the Link to share in the format:

https://docs.google.com/presentation/d/[...]/edit?usp=sharing

A link in this format is not part of the file resource object, nor it is returned from the http call setting the permissions. I hope someone can explain to me how to get this link through the REST api?

like image 291
Jon Saalbach Avatar asked Mar 04 '13 12:03

Jon Saalbach


People also ask

Can you get a link to a shared Google Drive?

Open or select the file or folder. Click Share or Share. Get link, Under “General access”, click the Down arrow.

How do I get a direct URL in Google Drive?

With Google Drive, you can store files in the cloud and share them easily with anyone. Open any file in Google Drive, click the Share button and you'll get a URL (link) that others can use to access your file.


1 Answers

You can use the alternateLink property in the File resource to get a link that can be shared for opening the file in the relevant Google editor or viewer:

https://developers.google.com/drive/v2/reference/files

Update

[With API V3](https://developers.google.com/drive/api/v3/reference/files it is suggested to use the webViewLink property.

like image 138
Claudio Cherubino Avatar answered Sep 28 '22 04:09

Claudio Cherubino