如何使用Google API检索文档的所有者或云端硬盘ID? [英] How to retrieve the owner or Drive ID of a document with Google APIs?

查看:153
本文介绍了如何使用Google API检索文档的所有者或云端硬盘ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Working with Google APIs (Sheet, v4) in JavaScript, I need to verify the origin of a sheet, either by using an owner ID or the Drive ID where it is hosted (regardless of the folder).

我查看了电子表格的属性以及文档,但是找不到这些基本信息.谢谢你.谢谢.

I looked at the properties of the Spreadsheet as well as the documentation but couldn't find this essential information. Thank you. Thank you.

以下是参考的文档: 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"
  }
}

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

No property contains any information about the owner or the Drive.

推荐答案

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

You can use the Drive API to get the email address of a file give the ID.

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

这篇关于如何使用Google API检索文档的所有者或云端硬盘ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆