我正在嘗試通過(guò)更新權(quán)限來(lái)更改 Google 云端硬盤(pán) API 的所有者:permissions = drive_api.files().get(fileId=ssId, fields='permissions').execute()['permissions'][{'displayName': 'account_name', 'emailAddress': 'account_email', 'id': 'id1', 'role': 'writer', 'type': 'user'}, {'displayName': 'api_email', 'emailAddress': 'api_email', 'id': 'id2', 'role': 'owner', 'type': 'user'}]我獲取我的帳戶(hù)權(quán)限 ID:for permission in permissions: if permission['emailAddress'] == 'account_email': permissionId = permission['id'] break拿身體看:body = drive_api.permissions().get(fileId=ssId, permissionId=permissionId).execute(){'id': 'id1', 'kind': 'drive#permission', 'role': 'writer', 'type': 'user'}更改角色:body['role'] = 'owner'并進(jìn)行更新:drive_api.permissions().update(fileId=ssId, permissionId=permissionId, body=body, transferOwnership=True).execute()但得到一個(gè)錯(cuò)誤:資源正文包括不可直接寫(xiě)入的字段
如何在Python中使用Google Drive API v3更改所有者?
函數(shù)式編程
2022-09-06 19:47:38