【发布时间】:2012-11-16 07:22:25
【问题描述】:
我无法访问 Google 云端硬盘。我在 Google API 控制台中创建了一个 API KEY 并启用了 Google Drive API 和 SDK。我在代码中的哪里设置 API KEY?
驱动器构建器没有setJsonHttpRequestInitializer 方法。我在哪里可以设置 KEY?有其他选择吗?
private Drive getDriveService(String token) {
HttpTransport ht = AndroidHttp.newCompatibleTransport();
JacksonFactory jsonFactory = new JacksonFactory();
Credential credentials = new GoogleCredential().setAccessToken(token);
Drive.Builder b = new Drive.Builder(ht, jsonFactory, credentials);
b.setHttpRequestInitializer(credentials);
return b.build();
}
获取:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "usageLimits",
"message" : "Access Not Configured",
"reason" : "accessNotConfigured"
} ],
"message" : "Access Not Configured"
}
【问题讨论】:
-
我遇到了同样的问题:stackoverflow.com/questions/13462952/google-drive-sdk-exception。你有没有机会弄清楚这一点?
标签: android google-drive-api google-drive-realtime-api