Tom*_*che 4 java google-drive-api
我正在尝试使用官方Java示例熟悉Google Drive API.但是,在浪费了几个小时并尝试将样品放置两次之后,我仍然无法按预期使用它.
它不是显示文件的内容,而是在FileServlet(/ svc路径)中抛出404错误.更具体地说,service.files().get(fileId).execute();似乎返回null.我已尝试使用不同的文件,不同的MIME类型,直接来自Google云端硬盘以及使用Google文件选择器.
我已尽可能地遵循https://developers.google.com/drive/examples/java中描述的步骤.
有没有人能够让样本运行?
编辑:
这是请求URL时FileServlet的日志输出/svc?file_id=0B08R9MrOE-ejZTY2M2I5MjAtYmVjZS00OTkyLWI4ZTEtOTg4OGM3YTIxMWEw(在第78行抛出404错误):
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"
}
}
Run Code Online (Sandbox Code Playgroud)
这听起来很像"我不认识你",所以我又看了一下我的客户端ID和客户端密码:我注意到API控制台中显示了两个客户端ID和客户端密钥,一个"Web应用程序的客户端ID"和另一个"Drive SDK的客户端ID".我之前使用过一个用于Web应用程序,所以我尝试切换到Drive SDK的那个.不幸的是,这并没有改变任何事情.同样的错误...:/
根据您的日志,您的404错误似乎是由对Drive API请求返回的403错误引起的.
来自Google API的错误通常包含其正文中的解释.在你的情况下:
"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"
}
}
Run Code Online (Sandbox Code Playgroud)
这通常意味着您尚未在Google API控制台项目中启用对Google Drive API的访问权限.为此:
这些都在我们文档的"入门">"注册应用程序"部分中进行了描述.您还应该确保通过" 入门"的其他子部分.
| 归档时间: |
|
| 查看次数: |
3310 次 |
| 最近记录: |