0

I'm working with Google Drive but from time to time I receive error from Google saying: (but only while trying to download file. removing or adding file is still working)

Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
  "code": 403,
  "errors": [
    {
      "domain": "usageLimits",
      "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
      "reason": "dailyLimitExceededUnreg",
      "extendedHelp": "https://code.google.com/apis/console"
    }
  ],
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}


Below is the code I'm using to get file stream from Google Drive:

    Credential credential = new GoogleCredential.Builder().setJsonFactory(GsonFactory.getDefaultInstance())
       .setTransport(getTransport()).setClientSecrets(secrets).build().setAccessToken(accessToken);
    Drive drive = Drive.Builder(getTransport(), GsonFactory.getDefaultInstance(), 
       getCredential(accessCode, googleClientSecrets)).setApplicationName("XXX").build();
    File file = drive.files().get(googleDocId).execute();
    String url = file.getExportLinks().get(googleMimeType);
    return drive.getRequestFactory().buildGetRequest(new GenericUrl(url)).execute().getContent();
1
  • 1
    I think the message 'Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.' says it all. Mar 14, 2014 at 14:16

1 Answer 1

0

The "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup." is misleading. It implies you've reached some kind of quota, but that is almost never the case.

The Drive quota for unauthenticated use is ZERO. So what the message is really telling you is that your Drive request isn't carrying an Auth token. You should trace the http and you will find that the requests that are failing are missing the Authorization header. As to why, well that's an exercise for the reader.

1
  • you were right. Authorization header was missing from the request. However it was quite hard to realize why. As it turns out, when access token is invalidated (after its life time), usually google returns 401 Unauthorized access exception (and I was handling it properly refreshing access token using refresh token). However when you try to download file from google drive and access token is not valid 403 Forbidden exception error is returned and I wasn't refreshing access token in that case which was the main problem
    – Martin
    Mar 19, 2014 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.