I am working on an ứng dụng using Google Drive. I want the user to lớn be able to nội dung files by link, setting the permissions lớn anyone & withLink as described in the Google Developers documentation.

Bạn đang xem: Simple url tricks for google drive you should know

However, I cannot figure out what links to share. When I share a tệp tin in the Google Drive browser interface, I see the link to giới thiệu in the format:


A liên kết in this format is not part of the file resource object, nor it is returned from the http hotline setting the permissions. I hope someone can explain lớn me how to lớn get this liên kết through the REST api?

nội dung
Improve this question
edited Oct 30, năm trước at 14:21

2,32866 gold badges3434 silver badges3939 bronze badges
asked Mar 4, 2013 at 12:58

Jon SaalbachJon Saalbach
35511 gold badge44 silver badges77 bronze badges
địa chỉ cửa hàng a phản hồi |

4 Answers 4

Sorted by: Reset to default
Highest score (default) Date modified (newest first) Date created (oldest first)
You can use the alternateLink property in the file resource khổng lồ get a link that can be shared for opening the file in the relevant Google editor or viewer:



(https://developers.google.com/drive/api/v3/reference/files it is suggested to lớn use the webViewLink property.

mô tả
Improve this answer
edited Sep 10, 2019 at 10:08

6,72733 gold badges3232 silver badges6363 bronze badges
answered Mar 5, 2013 at 5:53

Claudio CherubinoClaudio Cherubino
14.7k11 gold badge3333 silver badges4040 bronze badges
địa chỉ a bình luận |
To actually enable liên kết sharing using Google Drive API:

drive.permissions.create( fileId: "......", requestBody: role: "reader", type: "anyone", );Get the webLinkView value using:

const webViewLink = await drive.files.get( fileId: file.id, fields: "webViewLink").then(response => response.data.webViewLink);
Improve this answer
answered Feb 26, 2019 at 20:31


8,62422 gold badges4343 silver badges5555 bronze badges
địa chỉ cửa hàng a bình luận |
In my case using the PHP Api v3, for the links to be non-empty you must define that you request this field... & if you have the right permissions:

so something lượt thích this:

$file =self::$service->files->get("1ogXyGxcJdMXt7nJddTpVqwd6_G8Hd5sUfq4b4cxvotest",array("fields"=>"webViewLink"));
nội dung
Improve this answer
answered Feb 23, 2017 at 13:50
2,88322 gold badges2929 silver badges2727 bronze badges
showroom a comment |
Here"s a practical example on how lớn get the WebViewLink file property (A.K.A. File edit link):

$file = $service->files->get($file_id, array("fields" => "webViewLink"));$web_link_view = $file->getWebViewLink();OR

$sheetsList = $drive_service->files->listFiles(< "fields" => "files(id, name, webViewLink, webContentLink)",>);$web_link_view = $sheetsList->current()->getWebViewLink();Pay attention that you should load the tệp tin specifying which fields you wanna bring with it (In this case, webViewLink). If you don"t vị that, only id và name will be available.

Xem thêm: Messenger Bị Chặn Gửi Tin Nhắn Facebook Bao Lâu? Cách Không Nhận Tin Nhắn Người Lạ Trên Messenger

In case you need lớn adjust the tệp tin sharing settings, this is how you bởi it:

$permissions = new Google_Service_Drive_Permission();$permissions->setRole("writer");$permissions->setType("anyone");$drive_service->permissions->create($file_id, $permissions);Possible values for setRole() và setType() can be found here: https://developers.google.com/drive/api/v3/reference/permissions/create

cốt truyện
Improve this answer
answered Aug 7, 2020 at 15:02
Heitor AlthmannHeitor Althmann
13711 silver badge44 bronze badges
địa chỉ cửa hàng a comment |

Your Answer

Thanks for contributing an answer lớn Stack Overflow!

Please be sure khổng lồ answer the question. Provide details và share your research!

But avoid

Asking for help, clarification, or responding khổng lồ other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Facebook
Sign up using thư điện tử and Password

Post as a guest

email Required, but never shown

Post as a guest


Required, but never shown

Post Your Answer Discard

By clicking “Post Your Answer”, you agree lớn our terms of service, privacy policy & cookie policy

Not the answer you're looking for? Browse other questions tagged google-drive-api or ask your own question.

The Overflow Blog
Featured on Meta
get public shareble link after uploading tệp tin to google drive using nodejs
How lớn upload xlsx files lớn my own google drive, then convert them to lớn google spreadsheet & get the shareable link programmatically?
How to programmatically nội dung a google drive liên kết on android?
Get direct links for unauthorized users on Google Drive API
Google drive API shareable liên kết for public
Sharing files in Google Drive using Python
Get public liên kết to file with Google Drive SDK
how lớn get a temporary tải về link for a tệp tin by google drive api
Google Drive SDK - Get presentation's "Present" link
Sharing tệp tin in Google Drive with public
How to lớn get the link of a publicly shared file/folder
Linking khổng lồ kml/kmz files on Google Drive
Google Drive SDK Public tải về Link
Get liên kết to Google Drive presentation file
How can i know the original tệp tin name from google drive liên kết using c# code
quả táo IPA installation over the air using google drive
Google drive api: How to get the absolut liên kết (final) as returnment From my script
How to allow viewers to download a tệp tin through Google Drive API
Hot Network Questions more hot questions

Question feed
Subscribe to RSS
Question feed lớn subscribe lớn this RSS feed, copy & paste this URL into your RSS reader.

Stack Overflow
Stack Exchange Network
Site kiến thiết / hình ảnh © 2022 Stack Exchange Inc; user contributions licensed under cc by-sa. Rev2022.5.6.42057

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device và disclose information in accordance with our Cookie Policy.