如何使用服务帐户来传输Google文件的所有权 [英] How to use a service account to transfer ownership of a google file

查看:117
本文介绍了如何使用服务帐户来传输Google文件的所有权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下内容创建了服务帐户: https://developers.google.com/drive / web / delegation
我下载了这个文件,要求我下载它作为JSON文件,如果这有所帮助的话。



现在我该如何使用该服务帐户来启动使用应用程序脚本的所有权转移?

  function transferOwnership(){
var fileId =1YzwfuawY8OiFIw-nbUCagTUhrxmqH2PEyMmYz1NMT9A;

var p = {};
p.role =owner;
p.type =user;
p.value =email@ofnewowner.com;

Drive.Permissions.insert(p,fileId);
}


解决方案

使用服务帐户的所有权,通过应用程序脚本API,使用Spencer Easton提供的库和指令。

https://github.com/Spencer-Easton/Apps-Script -Drive-Service-Account-Libarary / blob / master / src / saDrive.gs


I created a service account using the following: https://developers.google.com/drive/web/delegation I downloaded the file it asked me to download as a JSON file if that makes a difference.

Now how do I use that service account to initiate an ownership transfer using app script?

function transferOwnership() {
  var fileId = "1YzwfuawY8OiFIw-nbUCagTUhrxmqH2PEyMmYz1NMT9A";

  var p = {};
  p.role = "owner";
  p.type = "user";
  p.value = "email@ofnewowner.com";

  Drive.Permissions.insert(p,fileId);
}

解决方案

I was able to successfully transfer ownership of a file using a service account, via app script api, by using the library and instructions provided by Spencer Easton.

https://github.com/Spencer-Easton/Apps-Script-Drive-Service-Account-Libarary/blob/master/src/saDrive.gs

这篇关于如何使用服务帐户来传输Google文件的所有权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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