简体   繁体   English

创建新的共享云端硬盘

[英]Creating a new Shared Drive

When I run the code below, which is taken from: https://developers.google.com/drive/api/v3/manage-shareddrives#python当我运行下面的代码时,该代码取自: https://developers.google.com/drive/api/v3/manage-shareddrives#python

# Create a new drive
        test_drive_metadata = {'name': 'Test Drive'}
        request_id = str(uuid.uuid4())
        test_drive = self.service.drives().create(
            body=test_drive_metadata,
            requestId=request_id,
            fields='id'
        ).execute()

I get "The user does not have sufficient permissions for this file."我得到“用户对此文件没有足够的权限。” This does not happen if I create files, if I list shared drives or anything else.如果我创建文件、列出共享驱动器或其他任何内容,则不会发生这种情况。 There are no other required scopes other than [' https://www.googleapis.com/auth/drive '].除了 [' https://www.googleapis.com/auth/drive '] 之外,没有其他必需的范围。

It should be noted that I am using a service account.应该注意的是,我使用的是服务帐户。 Are service accounts not allowed to create shared drives?是否不允许服务帐户创建共享驱动器? This is not documented anywhere as far as I am aware if this is the case.据我所知,如果是这种情况,任何地方都没有记录。

There doesn't seem to be any explicit documentation regarding this limitation, but considering that Service Accounts (without using DWD and impersonation) are supposed to manage application data, and not user data , it makes sense that they cannot be used to manage data that is shared with regular users.似乎没有任何关于此限制的明确文档,但考虑到服务帐户(不使用 DWD 和模拟)应该管理应用程序数据,而不是用户数据,因此它们不能用于管理以下数据是有道理的与普通用户共享。

Also, the use of Service Accounts to manage shared documents seems to be advised against, according to the official documentation :此外,根据官方文档,似乎建议不要使用服务帐户来管理共享文档

Using the service account as a common owner to create many shared documents can have severe performance implications.使用服务帐户作为共同所有者来创建许多共享文档可能会对性能产生严重影响。

On the other hand, since Service Accounts have certain limitations compared to regular accounts (for example, Event creation in Calendar), this could probably be one of these limitations.另一方面,由于服务帐户与常规帐户相比具有某些限制(例如,日历中的事件创建),这可能是这些限制之一。

In any case, in order to make sure that's the case, I'd suggest you to report this behaviour in this Issue Tracker component .无论如何,为了确保确实如此,我建议您此问题跟踪器组件中报告此行为

Reference:参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM