Google Apps管理员可以使用Drive SDK管理用户文件吗? [英] Can a Google Apps Admin manage users files with Drive SDK?

查看:108
本文介绍了Google Apps管理员可以使用Drive SDK管理用户文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的 Drive SDK 对于经过身份验证的用户非常有用。是否可以使用 Drive SDK 使用Google Apps管理访问来模拟其他域用户?



Doclist API可以执行但使用此工具管理和复制文件(pdf,jpg)是不可能的。



我用这段代码使用Java:

  credential_origine = new GoogleCredential.Builder()。setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId([from console from console api])
.setServiceAccountScopes(DriveScopes.DRIVE)
.setServiceAccountUser(user@domain.com)
.setServiceAccountPrivateKeyFromP12File(new File(key.p12))。build );

但是当我尝试为user@domain.com检索数据时出现错误。如果我评论 .setServiceAccountUser(user@domain.com),该代码对于我用于创建密钥的相同帐户非常有用。



在旧的DOCList API中,我们通过请求的URL来模拟另一个用户。它是否类似?

解决方案

您可以使用

一旦您在您的帐户中创建了服务帐户密钥,您就可以在服务帐户中创建服务帐户密钥API项目(来自 API控制台),您必须将此项目添加到授权列表在cPanel中的第三方应用程序。有关详情,请参阅此处
您需要使用的客户端ID是绑定到服务帐户密钥的帐户,并且看起来像< APP_ID> - < OTHER_KEY> .apps.googleusercontent.com $ b

由于您想管理其他用户文件,因此您必须授权Drive wide范围: https://www.googleapis .com / auth / drive



大多数客户端库负责为开发人员提取索赔代。如果您可以指定您打算使用哪种语言,我可以通过提供一段代码来帮助您开始更新此答案。


The new Drive SDK is very good for the authenticated user. Is it possible use Drive SDK using Google Apps administrative access to impersonate other domain users?

The doclist API can do it but it's not possible manage and copy files (pdf, jpg) with this tool.

I'm using Java with this code:

credential_origine = new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
                    .setJsonFactory(JSON_FACTORY)
                    .setServiceAccountId("[email from console api]")
                    .setServiceAccountScopes(DriveScopes.DRIVE)
                    .setServiceAccountUser("user@domain.com")
                    .setServiceAccountPrivateKeyFromP12File(new File("key.p12")).build();

But I get an error when I try to retrieve data for the user@domain.com. If I comment .setServiceAccountUser("user@domain.com") the code works great for the same account I used for creating the key.

In the old DOCList API we impersonated another user by the URL of the requests. Is it something similar?

解决方案

You can do that using Service Accounts and specifying the user to impersonate when building your assertion claim.

Once you have created a Service Account key in your API project (from the APIs Console), you will have to add this project to the list of authorized third party app in the cPanel. More information about this can be found here. The "Client Id" you need to use is the one bound to the Service Account key and looks like <APP_ID>-<OTHER_KEY>.apps.googleusercontent.com

Since you want to manage other users file, you will have to authorize the Drive wide scope: https://www.googleapis.com/auth/drive.

Most of our client libraries take care of abstracting the claim generation for developers. If you could specify which language your are planning to use, I can update this answer by providing a code snippet to help you get started.

这篇关于Google Apps管理员可以使用Drive SDK管理用户文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆