問題描述
我想列出來自谷歌域的所有文檔.我已經(jīng)嘗試過谷歌文檔中提到的: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
我創(chuàng)建了如下服務(wù):
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();
當(dāng)我按如下方式執(zhí)行此請求時:
When i am executing this request as follows :
FileList files = request.execute();
我只有userEmail
"(創(chuàng)建服務(wù)時提供)文件.
I got only 'userEmail
' (Provided while creating service) files.
如何獲取所有域 google 驅(qū)動器文件?我使用了超級管理員,但我無法獲得.
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:
- 使用您的服務(wù)帳戶和應(yīng)用設(shè)置域范圍的授權(quán).李>
- 使用目錄 API users.list() API 調(diào)用以確定 Google Apps 域中的所有用戶.
- 作為每個用戶,調(diào)用 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.
所有這些調(diào)用的組合結(jié)果將是您的 Google Apps 域中的所有文件.
The combined results of all these calls would be all files in your Google Apps domain.
這篇關(guān)于如何使用 Drive SDK 列出域中的所有 Google 文檔?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!