Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用Drive SDK列出域中的所有Google文档?_Java_Google App Engine_Google Drive Api - Fatal编程技术网

Java 如何使用Drive SDK列出域中的所有Google文档?

Java 如何使用Drive SDK列出域中的所有Google文档?,java,google-app-engine,google-drive-api,Java,Google App Engine,Google Drive Api,我想列出google域中的所有文档。我已经尝试了google文档中提到的: 我创建了以下服务: HttpTransport httpTransport = new NetHttpTransport(); JacksonFactory jsonFactory = new JacksonFactory(); GoogleCredential credential = new GoogleCredential.Builder() .setTransport(httpTransp

我想列出google域中的所有文档。我已经尝试了google文档中提到的:

我创建了以下服务:

 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();
当我按如下方式执行此请求时:

 FileList files = request.execute();
我只收到了“
userEmail
”(在创建服务时提供)文件

如何获取所有域google驱动器文件??我使用了超级管理员,但无法获取。

您不能:),因为Google驱动器文件所有权逻辑以用户为中心


您只能列出用于调用API的用户的“我的驱动器”中的文件。

要获取Google应用程序域中的所有文件,您需要:

  • 使用您的服务帐户和应用程序进行设置
  • 使用目录API调用确定Google应用程序域中的所有用户
  • 作为每个用户,调用以获取用户拥有的所有文件的列表
  • 所有这些调用的组合结果将是您的谷歌应用程序域中的所有文件