2

I can't access Google drive. I created an API KEY in Google API console and enabled Google Drive API and SDK. Where do I set that API KEY in code?

Drive builder does not have a setJsonHttpRequestInitializer method. Where can I set the KEY?Is there alternatives?

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();
}

Getting:

 com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
 {
   "code" : 403,
   "errors" : [ {
     "domain" : "usageLimits",
     "message" : "Access Not Configured",
     "reason" : "accessNotConfigured"
  } ],
  "message" : "Access Not Configured"
 }
MPelletier
  • 16,256
  • 15
  • 86
  • 137
user1826780
  • 51
  • 1
  • 1
  • 4
  • I am having the same issue: http://stackoverflow.com/questions/13462952/google-drive-sdk-exception. Have you been able to figure this out by any chance? – John Roberts Nov 20 '12 at 15:04

2 Answers2

5

You need to activate TWO things in the API console: - Drive API - Drive SDK

Many people activate only one.

Moreover, don't forget to add your real certificate SHA1 before releasing the final application.

There is this similar answer: Google Drive SDK Exception

Community
  • 1
  • 1
pommedeterresautee
  • 1,843
  • 1
  • 20
  • 24
  • After the whole day getting "internal error" from Google Play Services and re-adjusing API console settings, at least I've read this comment... Thanks, man! – Rodion Altshuler Jun 17 '14 at 14:55
1

In Android, as specified by pommedeterresautee we need to perform the activation of Both Drive API and Drive SDK, which then leads to the API Key.

This has to be set in the Android manifest inside the application tag and on par with other application component tags as :

<application...>
<activity ...>
<meta-data
        android:name="com.google.android.apps.drive.APP_ID"
        android:value="id=YOUR_API_KEY" />
</application>

When you do this, you will be able to access the api without a 403 "Access Not Configured" problem.

Sri Krishna
  • 302
  • 1
  • 2
  • 14