【发布时间】:2015-04-22 16:55:49
【问题描述】:
您好,我已经下载并安装了最新版本的 Drive REST API for java,并希望通过 fileID 从 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 密钥进行身份验证?如果需要,我将如何做。
感谢您的宝贵时间。
【问题讨论】:
标签: java api google-drive-api metadata