简体   繁体   English

通过 Google Drive API 将 Google Doc 设置为可供所有人共享和编辑

[英]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. 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 .我建议您首先在此处查看带有 Python 的 Drive API 快速入门。

Afterwards, in order to simulate the request you want, you can make use of the Try this API tool.之后,为了模拟您想要的请求,您可以使用Try this API工具。

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.至于在 Python 中应用此功能,您可以轻松地更新和调整快速入门中的代码,使其符合您的要求。

Reference参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过Google API更新Google驱动器上的文件后,如果不关闭IDLE窗口,则无法编辑本地计算机上的文件 - After updating file on google drive through google api, the file on local machine is not editable without closing IDLE window 如何通过Google API创建Google文档 - How to create a Google Doc through the Google API 通过 Google Drive API 访问共享驱动器时出现 404 错误 - 404 error when accessing a shared drive via Google Drive API 在共享驱动器中使用 Google Sheet API 创建 google sheet - Create google sheet using Google Sheet API in shared drive 如何从Colab / Jupyter中的共享Google云端硬盘链接获取文件? - How to get file from a shared Google Drive link in Colab/Jupyter? 通过Google Drive API从Google Sheet导出链接 - Exporting link from google sheet via google drive api 如何通过 Python 访问共享的 Google Drive 文件? - How to access shared Google Drive files through Python? Google Drive API 看不到共享文件夹中的文件 - Google Drive API Cannot See Files in Shared Folder 使用共享设备和服务帐户获取文件夹和文件 Google Drive API - Get folder and files Google Drive API with Shared Device and Service Account 谷歌驱动器 API:如何找到我与他人共享的所有文件 - Google drive API : How to find all files I shared with others
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM