久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 Google Drive API 從其他所有者刪除文件

Delete a file from different owner with Google Drive API(使用 Google Drive API 從其他所有者刪除文件)
本文介紹了使用 Google Drive API 從其他所有者刪除文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試做一個小型應用程序,它可以讀取與我組織的不同用戶共享的文件夾,獲取文件然后刪除它們.

I'm trying to do a small application that reads a shared folder with different users of my organization, get the files and then delete them.

問題是我無法刪除其他用戶的文件,因為我只能刪除我擁有的文件(收到 403 Insufficient permissions for this file)

The problem is that I can't delete the file of a different user, because I can only delete files of my ownership (receiving a 403 Insufficient permissions for this file)

我找到的另一個解決方案是更改文件的所有者,但我得到了同樣的錯誤.

Another solution I found is change the owner of the file, but I get the same error.

我使用本機應用程序 oAuth 以及組織的 SuperAdmin 帳戶和服務帳戶對其進行測試,但它們都不起作用.

I test it with a Native Application oAuth with a SuperAdmin account of the organization and with a service account, and none of them works.

我的一段代碼試圖改變所有權:

A piece of my code trying to change the ownership:

new_permission = {
    'value': "admin@organization.com",
    'type': "user",
    'role': "writer"
}
perm = drive_service.permissions().insert(fileId=idfield, body=new_permission).execute()
perm['role'] = 'owner'
drive_service.permissions().update(fileId=idfield, permissionId=perm['id'], transferOwnership=True, body=perm).execute()

我花了數小時搜索和嘗試找到的不同解決方案,但沒有一個有效(例如,文件所有權轉移失敗 - 即使作為超級管理員(Google Drive API,Java)).

I spend hours searching and trying different solutions I found, but no one works (for example, Transfer ownership of a file fails - even as Super Administrator (Google Drive API, Java)).

有人有什么想法嗎?謝謝!

Somebody has some idea? Thanks!

推薦答案

目前最好的解決方案包括兩個步驟:

The best solution right now involves two steps:

  1. 作為管理員帳戶,確定每個文件的當前所有者.
  2. 使用委托授權,模擬每個文件的所有者并將所有權轉讓給管理員帳戶.
  1. As the admin account, determine the current owner for each file.
  2. Using delegated authorization, impersonate the owner of each file and transfer ownership to the admin account.

所有者的電子郵件地址需要使用委托授權,但在 API 返回的權限對象中并不總是可見.如果出現以下任一情況,電子郵件地址將可見:

The email address of the owner is required to use delegated authorization, but isn't always visible in the permissions objects returned by the API. The email address will be visible if either:

  • 用戶擁有 Google+ 帳戶,其個人資料的聯系信息"部分包含他們的主要電子郵件地址,并且電子郵件地址的可見性設置為包含管理員帳戶的級別.
  • 用戶位于 Google Apps 域中,并且該域已在管理控制臺中的Google Apps > 聯系人 > 高級設置"下啟用聯系人共享.

這篇關于使用 Google Drive API 從其他所有者刪除文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Troubles while parsing with python very large xml file(使用 python 解析非常大的 xml 文件時出現問題)
Find all nodes by attribute in XML using Python 2(使用 Python 2 在 XML 中按屬性查找所有節點)
Python - How to parse xml response and store a elements value in a variable?(Python - 如何解析 xml 響應并將元素值存儲在變量中?)
How to get XML tag value in Python(如何在 Python 中獲取 XML 標記值)
How to correctly parse utf-8 xml with ElementTree?(如何使用 ElementTree 正確解析 utf-8 xml?)
Parse XML from URL into python object(將 XML 從 URL 解析為 python 對象)
主站蜘蛛池模板: 久久精品国产99国产 | 国产一区二区三区在线免费 | 美女在线观看av | 欧美在线一区二区三区四区 | 欧美日韩国产中文 | 成人久久视频 | 亚洲高清视频在线 | 亚洲在线| 一级在线毛片 | 伊人91在线| 日韩欧美国产精品一区二区 | 澳门永久av免费网站 | 一级做a毛片 | 午夜私人影院在线观看 | 亚洲精品在线观 | 综合激情av | 久久aⅴ乱码一区二区三区 91综合网 | 超碰在线人人干 | 欧美国产视频 | 国产高清精品一区 | 亚洲免费观看视频 | 狠狠干在线 | 日本精品视频 | 免费一看一级毛片 | 久草视频观看 | 欧洲视频一区二区 | 日日拍夜夜 | 久久草在线视频 | 欧美精品乱码久久久久久按摩 | 一区二区不卡 | 亚洲 精品 综合 精品 自拍 | 国产精品二区三区在线观看 | 成人一级毛片 | 久久久久久久久久毛片 | 男人的天堂在线视频 | wwwsihu| 女同久久另类99精品国产 | 玖玖操 | a级片在线观看 | 五月天国产 | 日韩精品免费在线 |