如何使用Drive SDK列出域中的所有Google文档? [英] How to list all Google document from the Domain using Drive SDK?

查看:335
本文介绍了如何使用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.

我如何获得所有域名谷歌驱动器文件?我使用了超级管理员,但我无法得到。

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:


  1. 设置使用您的服务帐户和应用程序进行全域授权

  2. 使用目录API users.list() API调用以确定Google Apps域中的所有用户。

  3. 作为每个用户,请致电 files.list(q ='me)在所有者')获取用户拥有的所有文件的列表。

  1. Setup domain-wide delegation of authority with your Service Account and Apps.
  2. Use the Directory API users.list() API call to determine all users in the Google Apps domain.
  3. 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文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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