Quota of requests Google API is exceed by few requests

Viewed 53

I have error in Google Drive API Requests: "Sorry, you have exceeded your sharing quota.", but it was few requests It was 235 requests evenly in five hours, and 30 errors last time (screenshot 1). All last requests get errors. But all limits are full at console (screenshot 2). What I do wrong? screenshot 1 screenshot 2

Requests is:

#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys, json, base64, time
import httplib2
import apiclient.discovery
from oauth2client.service_account import ServiceAccountCredentials


input_data = json.loads(base64.b64decode(sys.argv[1]))
user_mail = input_data['user_mail']
admin_mail = input_data['admin_mail']
donor_spreadsheet_id = input_data['donor_spreadsheet_id']

#donor_spreadsheet_id = '*****' #hided

CREDENTIALS_FILE = '*****.json'  #hided
scope = ['https://www.googleapis.com/auth/spreadsheets', 'https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name(CREDENTIALS_FILE, scope)

httpAuth = credentials.authorize(httplib2.Http())

driveService = apiclient.discovery.build('drive', 'v3', http=httpAuth)
try:
    new_spreadsheet = driveService.files().copy(fileId=donor_spreadsheet_id).execute()
except Exception as e:
    print('Copy error: ', json.loads(e.content)['error']['errors'][0]['message'])
try:
    shareRes = driveService.permissions().create(
        fileId = new_spreadsheet['id'],
        body = {'type': 'user', 'role': 'writer', 'emailAddress': user_mail}, 
        fields = 'id'
    ).execute()
except Exception as e:
    print('Adding user mail error: ', json.loads(e.content)['error']['errors'][0]['message'])

new_url = 'https://docs.google.com/spreadsheets/d/' + new_spreadsheet['id'] + '/'
print(new_url)
1 Answers

Sorry, you have exceeded your sharing quota.

Means exactly that, there are a few quotas attached to google drive. First off the quota you are hitting is not related to the api it self. so your not going to see it in google cloud console, as you can see in the picture.

Google cloud console only shows api related quotas. That being quotas that prevent us from flooding the api either per use or per project.

The quota you are hitting is a general google drive quota.

  1. There is a limit to how many people a file can be shared with. Last i knew it was around 250.
  2. there is also a limit to how many people you can share a file with in for a certain time frame.

Debugging it is going to take some time, as far as i know google has not actually documented the hard numbers. This would probably be due to the fact that if they change them they would have to update the docs.

How to debug.

Get the error then try and share it with one other person via the web app. If it wont let you then you have probably hit the max number of users a file can be shared with.

If you can then implement exponential backoff and try again to insert it via the api. I seem to remember there being a limit on the number of users a file can be shared with in a 4 hour period of time. Its been at least six years since i worked wit the client that was having this issue so that number may have changed.

If it is a flood quota then you may have to wait until midnight west cost usa for it to reset.

I have been looking and cant find any docs that give actual numbers.

I posted a question on the issue forum Sorry, you have exceeded your sharing quota. requesting documentation.

Update from google

enter image description here

Related