How to list all Google document from the Domain using Drive SDK?(如何使用 Drive SDK 列出域中的所有 Google 文档?)
问题描述
我想列出来自谷歌域的所有文档.我已经尝试过谷歌文档中提到的:https://developers.google.com/drive/v2/reference/files/list#examples
I want to list all the document from google domain.I have tried the as per mention in google documentation : https://developers.google.com/drive/v2/reference/files/list#examples
我创建了如下服务:
HttpTransport httpTransport = new NetHttpTransport();
JacksonFactory jsonFactory = new JacksonFactory();
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
.setServiceAccountScopes(Arrays.asList(DriveScopes.DRIVE))
.setServiceAccountUser(userEmail)
.setServiceAccountPrivateKeyFromP12File(
new java.io.File(SERVICE_ACCOUNT_PKCS12_FILE_PATH))
.build();
Drive service = new Drive.Builder(httpTransport, jsonFactory, null)
.setHttpRequestInitializer(credential).build();
Files.List request = service.files().list();
当我按如下方式执行此请求时:
When i am executing this request as follows :
FileList files = request.execute();
我只有userEmail
"(创建服务时提供)文件.
I got only 'userEmail
' (Provided while creating service) files.
如何获取所有域 google 驱动器文件?我使用了超级管理员,但我无法获得.
How i can get all domain google drive files ?? i have used super admin but i couldn't get.
推荐答案
要获取您的 Google Apps 域中的所有文件,您需要:
To get all files in your Google Apps domain you would need to:
- 使用您的服务帐户和应用设置域范围的授权.李>
- 使用目录 API users.list() API 调用以确定 Google Apps 域中的所有用户.
- 作为每个用户,调用 files.list(q='"me" in owner') 获取用户拥有的所有文件的列表.
- Setup domain-wide delegation of authority with your Service Account and Apps.
- Use the Directory API users.list() API call to determine all users in the Google Apps domain.
- As each user, call files.list(q='"me" in owners') to get a list of all files the user owns.
所有这些调用的组合结果将是您的 Google Apps 域中的所有文件.
The combined results of all these calls would be all files in your Google Apps domain.
这篇关于如何使用 Drive SDK 列出域中的所有 Google 文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 Drive SDK 列出域中的所有 Google 文档?


- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 转换 ldap 日期 2022-01-01
- 获取数字的最后一位 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01