简体   繁体   English

Google Sheets API v4 分享

[英]Google Sheets API v4 share

My Webapp is creating, writing and reading google sheets perfectly.我的 Webapp 正在完美地创建、编写和阅读谷歌表格。

But I cannot find anything in the documentation about how to share the newly created document.但是我在文档中找不到有关如何共享新创建的文档的任何内容。 I need to be able to give editing access to other individuals.我需要能够将编辑权限授予其他人。

我相信您需要使用Drive API (而不是 Sheets API)来完成此操作。

You can create permission and can share with any other user.您可以创建权限并与任何其他用户共享。 Below is the code snippet.下面是代码片段。

 var body = {
      'type': 'user',
      'role': 'reader',// reader/writer/organzier
      'emailAddress': 'xyz@gmail.com'
    };

    var drive=google.drive({version: 'v3',auth});

    drive.permissions.create({
      'fileId': "SheetId",  //sheetID returned from create sheet response
      'resource': body,
    }, function(err, response) {if (err) {
      console.error('error-------', err);
      return;
      } else{
        console.log(JSON.parse(JSON.stringify(response))) ;
      }
    });

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

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