2015-04-22 104 views
1

您好我已经下载并安装了适用于java的Drive REST API的最新版本,并且希望通过fileID获取Google Drive中的公共文件的元数据 - 我有以下代码:Java获取Google Drive上公共文件的元数据

private static final String APPLICATION_NAME = "test"; 
private static final String FILE_ID = "theFileId"; 


public static void main(String[] args) { 

    HttpTransport httpTransport = new NetHttpTransport(); 
    JacksonFactory jsonFactory = new JacksonFactory(); 

    Drive service = new Drive.Builder(httpTransport, jsonFactory, null).setApplicationName(APPLICATION_NAME).build(); 

    printFile(service, FILE_ID); 
} 


private static void printFile(Drive service, String fileId) { 

    try { 
     File file = service.files().get(fileId).execute(); 
     System.out.println("Title: " + file.getTitle()); 
    } catch (IOException e) { 
     System.out.println("An error occured: " + e); 
    } 
} 

但是,我收到错误消息:“未经验证的使用的每日限制超出,继续使用需要注册。”

我试过了https://developers.google.com/drive/v2/reference/files/get,结果很好。

当文件是公开的时候,我是否必须使用API​​密钥进行身份验证?如果是,我该怎么做。

谢谢你的时间。

回答

相关问题