我试图使用官方的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