Google云端硬盘:如何使用Python SDK转移所有权? [英] Google Drive: How do I transfer ownership using the Python SDK?

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

问题描述

我已经设置了一个服务帐户来复制用户上传的文件.如何将所有权转移到其他电子邮件地址?

I have setup a service account to copy a file a user uploads. How do I transfer the ownership to a different email address?

我有:

new_permission = {'value': 'me@example.com', 'type': 'user', 'role': 'owner', 'transferOwnership': True} # also tried "true" and "True"
r = service.permissions().update(fileId=id, permissionId=perm_id, body=new_permission).execute()

没有所有权转移,所有者仍然是我的服务帐户.

No transfer of ownership takes place and the owner continues to be my service account.

也没有错误发生;只是不会改变所有者.

No errors occur either; it just doesn't change the owner.

我还尝试通过 https://开发人员.google.com/drive/v2/reference/permissions/update .我收到200条回复,但所有者仍然是我的服务帐户,而不是"me@example.com":

EDIT #2: I've also tried via https://developers.google.com/drive/v2/reference/permissions/update with no luck. I receive a 200 response but the owner is still my service account rather than "me@example.com":

{
 "kind": "drive#permission",
 "etag": "\"xxxxxxx/xxxxxxx-x\"",
 "id": "xxxxxxxxxxx",
 "selfLink": "https://www.googleapis.com/drive/v2/files/myfileid/permissions/xxxxxx",
 "name": "myserviceaccount",
 "emailAddress": "myserviceaccount@developer.gserviceaccount.com",
 "domain": "developer.gserviceaccount.com",
 "role": "owner",
 "type": "user"
}

编辑#3:我还尝试了补丁"方法...得到的结果与更新"方法相同.

EDIT #3: I've also tried the "patch" method...I get the same result as the "update" method.

推荐答案

您是否尝试过使用

Have you tried using https://developers.google.com/drive/v2/reference/permissions/insert to insert the new owner and then updating the ownership as per your method?

这篇关于Google云端硬盘:如何使用Python SDK转移所有权?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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