Google云端硬盘REST API(服务器到服务器):不对帐户文件

时间:2016-05-20 09:26:50

标签: google-drive-api

我尝试从我的应用程序中获取Google云端硬盘文件列表(简单的Google帐户)(https://developers.google.com/identity/protocols/OAuth2ServiceAccount

  1. OAuth2授权列表完美无缺:https://developers.google.com/drive/v3/reference/files/list#try-it

  2. 我已创建服务帐户并委托Google Apps域(https://console.developers.google.com/iam-admin/serviceaccounts): enter image description here并下载json服务密钥。

  3. 从应用程序申请GD:

    private static HttpTransport HTTP_TRANSPORT;
    private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
    
    
    static {
      try {
        HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
      } catch (Throwable t) {
        t.printStackTrace();
        System.exit(1);
      }
    }
    
    public static void main(String[] args) throws IOException {
      Credential credential = GoogleCredential
            .fromStream(new FileInputStream(".\\config\\google_drive_api.json"))
            .createScoped(DriveScopes.all());
    
      Drive service = new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName("javawebinar-1314").build();
    
      FileList result = service.files().list().execute();
      List<File> files = result.getFiles();
      System.out.println(files.size());
    
  4. API工作:开头的结果是单一的&#34;入门&#34;文件,现在结果是0.似乎服务帐户与我自己没有任何关系,并且委托给doman对我没有任何影响,因为我没有域帐户。

    是否有可能通过REST API管理我的简单谷歌帐户谷歌驱动器文件?

0 个答案:

没有答案