问题描述
我想列出来自谷歌域的所有文档.我已经尝试过谷歌文档中提到的: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 文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!