Daily Limit Error Message with Google Drive - google-drive-api

I am getting an error message when trying to use the Google Drive API to get a file. Using Python, the line that causes error is:
file = service.files().get(fileId=googleDriveFileId).execute()
The error message is:
HttpError: <HttpError 404 when requesting
https://www.googleapis.com/drive/v2/files/0B6Cpn8NXwgGPSE8zQW10XzJMc0k?alt=json returned
"File not found: 0B6Cpn8NXwgGPSE8zQW10XzJMc0k">
Basically saying "File not found"
However, if I put the URL being requested into browser, I get a different error message:
https://www.googleapis.com/drive/v2/files/0B6Cpn8NXwgGPSE8zQW10XzJMc0k
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit Exceeded. Please sign up",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit Exceeded. Please sign up"
}
}
Neither of these error messages seem correct to me. I know the file is there. Here is a working link to the same file retrieved from "Share Link" in the Google Drive UI:
https://docs.google.com/file/d/0B6Cpn8NXwgGPSE8zQW10XzJMc0k
I have also checked the Quota reports in the api console, and we are at 0% usage.
Any ideas what is going on here?
Thanks

I had similar errors following the python quickstart.
It turned out I had correctly created an API key etc, however had missed step 2:
Select the Services tab in your API project, and enable the Drive API.
Having used the API before I skipped along and missed this crucial point.

Both of the error messages did not have accurate info. The problem was related to permissions. I was using Google Picker to upload the files in question, but these files were not automatically available to the API because of permissions. I thought they would be according to documentation.
I solved problem by setting the permissions for the folder the images are being uploaded to for "Public" using the Google Drive UI. Now my app has permission to access the uploaded files.
While setting files permission to "Public" is okay in my case, as these files are meant to be public, I know this would not be acceptable in all cases. Can someone please shed light on how to handle this problem.... so that files uploaded with Google Picker automatically have the permission to be accessed by the API without setting folder permissions to "Public"?

The messages were accurate.
In the first case, because you don't have permission, Google gives a file not found. This is a standard security measure, rather than leak information by confirming the file exists.
In the second case, you called the API without an Authentication Header, so Google treats you as an unregistered and unauthorised app, which for some Google APIs is OK, up to a a daily quota. In the case of Drive, that daily quota is zero.
I agree it's not intuitive, and I'm sure many developer man years have been wasted (mine included), but it is accurate.
To answer your question about why the uploaded file is inaccessible, check that you have requested the correct scope, and that you are using the correct client id and mime type when doing the upload.

Related

dailyLimitExceededUnreg error on authenticated download requests for abusive files

I'm getting the following error when trying to download files from my Google Drive folder using JavaScript.
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
I'm using googleapis library, version v3 with OAuth2 authorization.
My function downloads most of the files correctly but throws an error on some specific ones each time I run it.
The library itself prints cannotDownloadAbusiveFile error in the console but the response link shows the error above.
The acknowledgeAbuse flag is set to true. The files that this method refuses to download can't be downloaded from the web-interface either because of the viruses.
I tried changing the Google Drive user in OAuth2 to the creator of the files (it was just someone who has access before), it didn't fix anything.
Daily Limit for Unauthenticated Use Exceeded.
Means there is an issue with your authorization at some point you are sending a request with either a missing access token or an expired one.
As for cannotDownloadAbusiveFile you can set a flag in your request it should be one of the optional parameter's. acknowledgeAbuse='true' this will allow you to download files that Google has denoted as unsafe. If it contains malware though from what i recall only the owner can download that.

Google Drive API failing - Unusual traffic from your computer network

The Google Drive API GET query started to fail (we are using this api in one of our client service):
https://www.googleapis.com/drive/v3/files/1ke4Yoxxxxxxxxxxxxxx?alt=media&access_token=ya29.ImG9BwT.....
We're sorry...
... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.
See Google Help for more information...
"Unusual traffic from your computer network"
Everything was ok till today.
Just made a couple of tests with curl:
HTTP GET with access_token inside HTTP header:
curl -H "Authorization: Bearer ya29._valid_access_token" https://www.googleapis.com/drive/v3/files/1r5BT2WPrulQ6FyhT8RcqV51TVOThEmhK?alt=media
Result: success, file downloaded.
HTTP GET with access_token as a part of HTTP request:
curl https://www.googleapis.com/drive/v3/files/1r5BT2WPrulQ6FyhT8RcqV51TVOThEmhK?alt=media&access_token=ya29._valid_access_token
Result: error
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
Note that the Google API project approved by Google and has a Production state!!!
Hi Google team, any ideas why it is happening?
Thank you
Posting this just for documentation purposes. As per the reference provided by Tanaike, since January 1, 2020:
download calls to files.get, revisions.get and files.export endpoints which authenticate using the access token in the query parameter will no longer be supported.
Only requests that download media content (alt=media) are affected by this change.
The access token should be provided in the HTTP header, like Authorization: Bearer oauth2-token or, if that's not possible, follow the workarounds provided in the referenced documentation:
For file downloads, redirect to the webContentLink which will instruct the browser to download the content. If the application wants to display the file to the user, they can simply redirect to the alternateLink in v2 or webViewLink in v3.
For file exports, redirect to the export link in exportLinks with the desired mime type which will instruct the browser to download the content.
Reference:
Changes in authorization to Google Drive API
Authorization via HTTP header
Posting an addition to the documentation of iamblichus specific for application data in Google Drive.
My App uses the Google Drive API in the backend to store the documents of my users on their own Drive. Importantly, I store the data in an application data folder such that the users can't accidently delete the data.
To let the users retreive their documents I used to redirected the user to the
downloadUrl: https://www.googleapis.com/drive/v2/files/id?alt=media&source=downloadUrl&access_token=ya29.** where I added alt=media and access_token to the query. This worked fine till January 1, 2020. As confirmed above. However, now the request fails with the message:
We're sorry... ... but your computer or network may be sending
automated queries. To protect our users, we can't process your request
right now.
GET request downloadUrl failing
In my efforts to find a solution to this problem I've tried the workarrounds provided by Google but they are in my experience not working for documents in an application data folder.
I tried the webContentLink with the access_token query in v2 but it fails with an 401 Unauthorized error.
The alternateLink in v2 and the webViewLink in v3 fail with the error:
The desired file does not exist.
I can't use the exportLinks because that's only for Google Documents.
The solution I found was to first download the file to the server using the Google Drive PHP SDK and then serve it to my users using a Content-Dispostion header. Such as described here. It is a lot less elegant in my opinion because the end users doesn't download the document directly from the Google Drive API but it works.
It's a shame that Google didn't update their documentation nor notified their users..

Google Drive Error: Registered app required, either through authentication token or key param

Suddenly today requests from my service attempting to insert a file into Google drive via the Drive API started to receive a 400 error. The error indicates that a registered app is required, full error below. An application was already registered in my Google Cloud console, however the applications name did not match the application name that was used by my service. I renamed the services application name, however the error continues.
400 Bad Request
{
"code": 400,
"errors": [
{
"domain": "global",
"message": "Registered app required, either through authentication token or key param.",
"reason": "required"
}
],
"message": "Registered app required, either through authentication token or key param."
}
Is there something else that needs to be setup, or could this be a delay in the renaming of the service?
EDIT: I'm able to list, update and download files however I cannot insert.
This same issue just started to happen to us today - and we made no changes. I (think I) submitted a bug report to Google about this. Will keep digging..
UPDATE: I created a new project with private key and client ID/email and I get the same error with this new project as well. This appears to be some bug with Google Drive API service.
It happens today on my app too. I guess their service is having problem today

Google Drive download limit / throttle on individual file downloadUrls?

I'm seeing a 403 "Access to the webpage was denied" error on one specific file being accessed via the Drive SDK. It was working earlier, the app permissions are set correctly, and we're having success with other files using different tokens against the same app.
We're getting the downloadUrl from the SDK successfully, then seeing the error message only after users are redirected to the downloadUrl. Because of that it's hard to track, but we've confirmed that it's working for some, but not for others — it hasn't fully stopped.
The full error text is:
Access to the webpage was denied
You are not authorized to access the webpage at [...] You may need to sign in.
HTTP Error 403 (Forbidden): The server refused to fulfill the request.
We're including the GET download and (valid) access_token parameters, all that.
My question is this: could this be related to the reported Google Drive outage that's currently happening, or is there some sort of throttle/limit to access of a single file over the drive API? I've never seen this behavior before, and this response isn't listed among the standard 403 responses.
I have just seen something similar. I was using a freshly acquired access token, so I don't think it's oauth related. My working theory is that the downloadUrl link was stale. When I got fresh meta data, which had a different value in downloadUrl, it worked using the same access token that had previously failed.
This is only a theory since it isn't documented anywhere, and I would actually expect 410 (or even 301) as a much more appropriate status than 403.

Google Drive authentication. Do I need special permissions to get full drive access in a domain?

I've made an application that manages files in the google drive. During dev I used a
gmailadress:user#gmail.com
Now I'm using: user#googleappsdomain.com
and the authentication stopped working. I keep getting 401 not authorized. Do I need special permissions to get full drive access in a domain?
This is the error the webserver gives me.
{
"code" : 401,
"errors" : [ {
"domain" : "global",
"message" : "Invalid Credentials",
"reason" : "authError"
} ],
"message" : "Invalid Credentials"
}
Error when I try the quickstart example with the other email adress. (Works fine with my gmail adress).
When i'm using OAuth 2.0 Playground I get the same 401 error with my apps address on step 3 when I request Files.List...
I found this:
http://support.google.com/a/bin/answer.py?hl=en&answer=162106
Is this the setting I'm looking for?
It doesn't say anything about the drive scope..
Correction.
The short answer to "Do I need special permissions to get full drive access in a domain?" is yes.
https://www.google.com/a/cpanel/YOURDOMAIN.COM/ServiceSettings#ServiceSettings/service=drive+and+docs&subtab=general
To prove to yourself that it should work, try running the "try it" at https://developers.google.com/drive/v2/reference/files/list#try-it
From there you can work backwards through oauth playground and then your own code to see what's different.
You need to clear your credentials, and get a new set for the new user. I suspect you are using some stored credentials somewhere, or have issues with being logged into more than one account at once.