我无法访问Google驱动器。我在Google API控制台中创建了一个API KEY,并启用了Google Drive API和SDK。我在哪里设置代码中的API KEY?如何使用Google驱动器API密钥从Android应用程序访问驱动器内容?
驱动器生成器没有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"
}
我遇到同样的问题:http://stackoverflow.com/questions/13462952/google-drive-sdk-exception。你有没有能够解决这个问题? –