【问题标题】:How to retrieve the owner or Drive ID of a document with Google APIs?如何使用 Google API 检索文档的所有者或 Drive ID?
【发布时间】:2019-11-26 23:38:55
【问题描述】:

在 JavaScript 中使用 Google API(Sheet,v4)时,我需要使用所有者 ID 或托管工作表的驱动器 ID(无论文件夹如何)来验证工作表的来源。

我查看了电子表格的属性以及文档,但找不到这些重要信息。谢谢你。谢谢。

这里是查阅的文档:https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.developerMetadata

{
  "spreadsheetId": "1kbxkHPzlHy35v9hNSE8pxJljF_MsTBqXER2xIFzm0W0",
  "properties": {
    "title": "Goco",
    "locale": "fr_FR",
    "autoRecalc": "ON_CHANGE",
    "timeZone": "Europe/Paris"
  }
}

没有属性包含有关所有者或驱动器的任何信息。

【问题讨论】:

  • 您的答案包含在您的问题中,您可能不知道。文档的用户是通过驱动 api 访问的,而不是 sheet api。

标签: google-apps-script google-sheets google-drive-api


【解决方案1】:

您可以使用 Drive API 获取文件的电子邮件地址并提供 ID。

function getOwner() {
  var file = DriveApp.getFileById(spreadsheetId);
  Logger.log(file.getOwner().getEmail());
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多