使用Python将成员添加到Google Drive共享驱动器

问题描述

如何将成员添加到Google云端硬盘的共享云端硬盘?

我正在研究Colab,并尝试进行搜索,但没有发现有用的信息。

我尝试使用PyDrive,但是:

  • 我无法选择整个共享驱动器,只能选择一个文件

  • 即使我无法通过Google云端硬盘网络GUI进行操作,我也无法更新该文件夹的权限

这就是我现在正在做的(错误400):

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
from google.colab import drive as drv
drv.mount('/gdrive',force_remount=True)
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

%cd /gdrive/Shared\ drives/

file_list = drive.ListFile({'q': "  title = 'FolderTitleOrSharedDriveTitle'"}).GetList()
for file1 in file_list:
  print('title: %s,id: %s' % (file1['title'],file1['id']))
  file = file1
print(file['title'])
file.GetPermissions()

new_permission = {
    'type': 'user','value': '[email protected]','role': 'reader'
}
permission = file.auth.service.permissions().insert(fileId=file['id'],body=new_permission,supportsAllDrives=True).execute(http=file.http)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)