首页 文章

使用API拥有Google Cloud 端硬盘文件和服务帐户的所有权

提问于
浏览
0

在开发人员控制台中为特定应用程序用户(例如user@mydomain.com)创建的服务帐户是否可以访问应用程序用户的文档?如果我在_1167308中设置帐户,如下所示:

$credentials = new Google_Auth_AssertionCredentials(...);
$credentials->sub = "user@mydomain.com";

我收到以下错误:

PHP Fatal error:
Uncaught exception 'Google_Auth_Exception' with message
'Error refreshing the OAuth2 token, message:'{
  "error" : "unauthorized_client",
  "error_description" : "Unauthorized client or scope in request."
}

当我没有设置 $credentials->sub = "user@mydomain.com" 我能够访问驱动器但我只看到一个文档“如何开始使用驱动器” .

如果我在服务帐户上创建文档,有没有办法将文档的所有权转移到我的应用程序帐户而不启用域范围授权?

2 回答

  • -1

    在Drive REST API中,服务帐户本质上是他们自己的帐户,但是这种行为似乎与Google Calendar API不一致,其中服务帐户可以模拟所有者帐户 without 域范围的委派 . 如果您使用开发人员控制台中提供的服务帐户电子邮件地址共享任何文档,该文档可供服务帐户访问,则无法进行所有权转移,因为这两个帐户在同一域中不存在 .

  • 0

    Do Service Accounts created in the Developer's Console for a specific apps user (e.g. user@mydomain.com) have access to the app user's documents?

    没有

    I am able to access the drive but I only see the one document "How to get started with Drive".

    你有什么期望?您已经创建了一个新帐户,因此它只有一个欢迎文件 .

    If I create the document on the Service Account, is there any way to transfer ownership of the document to my apps account without enabling domain wide delegation?

    您确定您已了解服务帐户是什么吗?如果您需要帐户中的文件,请使用您帐户的令牌并停止使用中间服务帐户 .

相关问题