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 文档?
基础教程推荐
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 从 python 访问 JVM 2022-01-01
