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密鑰進行身份驗證?如果是,我該怎麼做。
謝謝你的時間。
但我可以忽略客戶端ID的東西是正確的,還是這也是必需的? – Sonni