6

We have an application that manages the sharing permission for Google Drive files and folders using the Drive API. When our application tries to update the sharing settings of certain files or folders we get a 'sharingRateLimitExceeded' error:

Caused by: com.google.api.server.spi.response.UnauthorizedException: 403 FORBIDDEN {   "code" : 403,   "errors" : [ {
    "domain" : "global",
    "message" : "Rate limit exceeded. User message: \"These item(s) could not be shared because a rate limit was exceeded: SupportMenuItem.class\"",
    "reason" : "sharingRateLimitExceeded"   } ],   "message" : "Rate limit exceeded. User message: \"These item(s) could not be shared because a rate limit was exceeded: FILENAME\"" }

We already configured the API call to not send emails and our service account impersonates different users when changing permissions to avoid exceeding rate limits.

How do we find out which sharing limit is being exceeded? And once we know which sharing limit is being exceeded, where can we find how high that sharing limit is? Is it a per minute sharing limit or a per day sharing limit? We need more information on the error so we can adjust our script so the sharing limits are not exceeded anymore. The information on the error in the documentation is to limited to be of any value to us.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • How many requests per second are you sending? Many of Google's services, especially Drive, have a crude rate-limiting algorithm which kicks in after 25 or so requests in rapid succession, and then effectively limits updates to approx 1 ever 1.5 seconds. – pinoyyid Oct 20 '17 at 08:22
  • Normally the request limit for the Drive API is 100 per second but Google increased that to 500 per second for us. If get a normal rate limit exceeded error we retry the request which solves the issue. When we retry requests from a sharingRateLimitExceeded error these are never successful. – Erik van den Hoorn Oct 23 '17 at 13:51
  • There are two separate limits. Regardless of the rate limit configured in the console, there is a DoS limit that is enforced using a token/bucket algorithm. So when you say "When we retry requests from a sharingRateLimitExceeded error these are never successful", how long are you backing off for before you submit the retry? – pinoyyid Oct 23 '17 at 15:07
  • We use exponential backoff, so it depends on the number of previous attempts how long the backoff is. – Erik van den Hoorn Oct 24 '17 at 15:03

1 Answers1

5
{   "code" : 403,   "errors" : [ {
        "domain" : "global",
        "message" : "Rate limit exceeded. User message: \"These item(s) could not be shared because a rate limit was exceeded: SupportMenuItem.class\"",
        "reason" : "sharingRateLimitExceeded"   } ],   "message" : "Rate limit exceeded. User message: \"These item(s) could not be shared because a rate limit was exceeded: FILENAME\"" } 

There is a limit to how many permissions you can insert in a day. That being around 50 in a 24 hour period of time you appear to have hit that quota. It should reset at mid night west cost usa time.

To my knowledge there is no way to extend this quota.

Documentation Handeling API errors

403: Sharing Rate Limit Exceeded

The user has reached a sharing limit. This is often linked with an email limit.

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "message": "Rate limit exceeded. User message: \"These item(s) could not be shared because a rate limit was exceeded: filename",
    "reason": "sharingRateLimitExceeded",
   }
  ],
  "code": 403,
  "message": "Rate Limit Exceeded"
 }
}

Suggested actions:

Do not send emails when sharing lot of files. If one user is making a lot of requests on behalf of many users of a G Suite domain, consider a Service Account with authority delegation to impersonate the owner of each document to share (setting the quotaUser parameter).

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • We make about 31 million requests per month distributed over 130 users. About 25 million request are successful. 2.4 million permission create and 2.5 million permission update requests fail due to rate limit errors. If requests dont succeed due to rate limit errors they are retried and mostly succeed. When we get a sharingRateLimitExceeded error and retry the request this is never successful. Therefore we need more info on this specific error. In any case the requests our application generates often exceed the 50 permission updates per user per 24 hours. – Erik van den Hoorn Oct 23 '17 at 13:43
  • There is no more info on that error other than what is in the documentation. Once you hit the error you are going to have to wait, until midnight west cost USA time before the user will be able to make the request again. – Linda Lawton - DaImTo Oct 23 '17 at 13:46
  • I don't even think waiting till midnight time USA would solve the problem as I sometimes get the error on one file when sharing lots of files but can continue with the rest of them. – mrnovalles Nov 02 '19 at 16:41