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