我試圖使用官方的Java示例來熟悉Google Drive API。然而,在浪費了幾個小時並試圖將樣品放置兩次之後,我仍然無法按預期使用它。Google Drive SDK - Java示例不能正常工作
不是顯示文件的內容,而是在FileServlet(/ svc路徑)中拋出404錯誤。更具體地說,service.files().get(fileId).execute();
似乎返回null。我已經嘗試過使用不同的文件,不同的MIME類型,直接從Google雲端硬盤以及使用Google文件選取器。
我已儘量按照https://developers.google.com/drive/examples/java處描述的步驟操作。
有沒有人能夠獲得樣品運行?
編輯: 請求URL /svc?file_id=0B08R9MrOE-ejZTY2M2I5MjAtYmVjZS00OTkyLWI4ZTEtOTg4OGM3YTIxMWEw
時,這裏的FileServlet的日誌輸出(404錯誤是在管線78扔):
2012-04-26 08:21:36.077
com.google.api.client.http.HttpRequest execute: -------------- REQUEST --------------
GET https://www.googleapis.com/drive/v1/files/0B08R9MrOE-ejZTY2M2I5MjAtYmVjZS00OTkyLWI4ZTEtOTg4OGM3YTIxMWEw
Accept-Encoding: gzip
User-Agent: Google-HTTP-Java-Client/1.8.3-beta (gzip)
D 2012-04-26 08:21:36.263
com.google.api.client.http.HttpResponse <init>: -------------- RESPONSE --------------
403 OK
content-type: application/json; charset=UTF-8
content-encoding: gzip
date: Thu
date: 26 Apr 2012 06:21:36 GMT
expires: Thu
expires: 26 Apr 2012 06:21:36 GMT
cache-control: private
cache-control: max-age=0
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
content-length: 188
server: GSE
x-google-cache-control: remote-fetch
via: HTTP/1.1 GWA
D 2012-04-26 08:21:36.265
com.google.api.client.http.HttpResponse getContent: Response size: 188 bytes
D 2012-04-26 08:21:36.271
com.google.api.client.http.HttpResponse getContent: {
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit Exceeded. Please sign up",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit Exceeded. Please sign up"
}
}
這聽起來很像「我不知道你「,所以我又看看了我的客戶端ID和客戶端密鑰:我注意到在API控制檯中顯示了兩個客戶端ID和客戶端密碼,一個是」Web應用程序的客戶端ID「,另一個是」 Drive SDK的客戶端ID「。我之前使用過一個用於Web應用程序的版本,因此我試圖切換到Drive SDK的版本。不幸的是,這並沒有改變任何東西。同樣的錯誤...:/
您可以更改[logging.properties](https://code.google.com/p/google-drive-sdk-samples/source/browse/java/war/WEB-INF/logging.properties#13 )記錄API請求的更多細節並向我們展示響應正文? – Alain 2012-04-25 21:46:23
FWIW,我寫了樣本及其指南。你能否給我一個確切的行號碼來產生404?/svc請求什麼網址? GET/svc需要file_id參數。 – 2012-04-26 04:58:02
@VicFryzel,謝謝你們!我更新了日誌輸出的帖子。 – TomTasche 2012-04-26 06:35:33