简体   繁体   中英

Set Google Doc to shared and editable by everyone with the link through Google Drive API

I'm not sure how to accomplish this in Python - I've understood how to create a Google Doc using the docs API, but I'm struggling on understanding the Drive API and how to use it with Python.

The documentation makes it clear that I have to insert a permission with 'editor' and 'everyone' somewhere, but I'm not sure what the actual code should be. Any help?

I suggest you start by taking a look at the Drive API Quickstart with Python here .

Afterwards, in order to simulate the request you want, you can make use of the Try this API tool.

So as to update the permissions of a file, the request will have to look something similar to this:

Request

PATCH https://www.googleapis.com/drive/v3/files/fileId/permissions/permissionId

Body

{
  "kind": "drive#permission",
  "role": "YOUR_ROLE"
}

As for applying this in Python, you can easily update and adapt the code from the quickstart such that it fits your requirements.

Reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM