首页 > 解决方案 > 授予作者权限时如何防止 Google Drive API v3 发送通知电子邮件?

问题描述

我可以writer使用 Google Drive API (v3) 授予权限。这是端点:

POST https://www.googleapis.com/drive/v3/files/FILE_ID/permissions"

API 参考说我应该使用sendNotificationEmail: false(注意,这是一个布尔值而不是字符串),这就是我正在做的事情(在 v2 中,这被称为sendNotificationEmails)。

在此处输入图像描述

但是,在通话后,我仍然收到来自 Google 的电子邮件,说我已被邀请编辑文件。

标签: google-drive-api

解决方案


sendNotificationEmail: false按预期工作,有一个小细节:

它是一个超出资源主体的请求参数。

我不确定您使用的是哪种语言,例如 Javascript,请求将是:

gapi.client.drive.permissions.create({
      "fileId": "XXX",
      "sendNotificationEmail": false,
      "resource": {
        "role": "writer",
        "type": "user",
        "emailAddress": "test@gmail.com"
      }
    })

推荐阅读