How to transfer File Ownership for a Document which admin doesn't own?

时间秒杀一切 提交于 2019-12-07 18:03:36

问题


Use Case

  • As admin service account, transfer Document Ownership using the Google Docs API, similar to the built in cPanel "Advanced Tools" -> "Document ownership transfer"

Constraints

  • APIs are being invoked in context of a Google Apps admin service account rather than the end-user account since APIs are being invoked from Google Apps Script in Sites page

  • Authorization is OAuth 1.0 since this is what Apps Script supports

What works:

  • Transferring ownership of the admin service account's own files to another user's account as documented here

What is required:

  • Transfer ownership of another user's files, ideally without them sharing any permissions with the admin service account; if there's no other way of doing it, they could share edit permissions on the file with the admin service account.
  • Currently this returns a

    " ServiceException - You do not have permission to share these item(s):"


回答1:


What you're trying to do is possible by impersonating the user using the admin account. The documentation shows how to do this here.

Essentially, start by requesting the API URL with default replaced with the current owner's email address. The request must be made while authorized as the admin user, though.

https://docs.google.com/feeds/user@yourdomain.com/private/full/

Once that URL is requested, all feed URLs will be returned with that email already present. Then, simply change ownership as you would normally.



来源:https://stackoverflow.com/questions/10050404/how-to-transfer-file-ownership-for-a-document-which-admin-doesnt-own

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!