"Insufficient tokens for quota 'ReadGroup' and limit 'USER-100s' of service
See original GitHub issueI have a code that works daily on both versions of API and was working as early as this morning(13th Aug '18). It took data from a bunch of sources and updates the sheet. It works on both v3 and v4 of the API.
Environment info
Operating System: Windows 10 17134 Python version: 3.7 gspread version: 3.0.1 and 0.6.2
Steps to reproduce
I have a bunch of sheets that all have the same format so I created a class to extract all the data I usually use. The class code is:
class gsheet():
def __init__(self,myFile,mySheet,json=None):
if json == None:
clientKey = fileopenbox()
else:
clientKey = json
scope = ['https://spreadsheets.google.com/feeds','https://www.googleapis.com/auth/drive']
cred = ServiceAccountCredentials.from_json_keyfile_name(clientKey,scope)
client = gspread.authorize(cred)
self.sheet = client.open(myFile).worksheet(mySheet)
self.POs = self.sheet.col_values(1)
self.rows = len(self.POs)
self.orders = self.sheet.col_values(5)
self.sup_orders = self.sheet.col_values(6)
self.skus = self.sheet.col_values(8)
self.tracking = self.sheet.col_values(26)
self.shipmeth = self.sheet.col_values(27)
def createRec(self, pl, row):
for p in list(pl.keys()):
vaL = pl[p]['value']
col = pl[p]['sheetCol']
self.sheet.update_cell(row,col,vaL)
and the actual execution code that four instances of the class, with all the calls for the attributes, and then pulls data from different sources and executes this code to update the appropriate cells:
if PO.startswith('C'):
mySheet = mywb if index_of(mywb.POs,PO) > -1 else mywbn
else:
mySheet = my3p if index_of(my3p.POs,PO) > -1 else my3pn
rowfill = [i for i,x in enumerate(mySheet.POs) if x.startswith(PO)]
for row in rowfill:
thisRow = row+1
if mySheet.sheet.cell(thisRow,38).value == 'Y':
continue
mySheet.sheet.update_cell(thisRow,26,track)
if handle == 3.95:
mySheet.sheet.update_cell(thisRow,19,handle/len(rowfill))
if freight:
mySheet.sheet.update_cell(thisRow,18,float(freight)/len(rowfill))
Stack trace or other output that would be helpful
File "<stdin>", line 1, in <module>
File "c:/Users/muddi/Google Drive/sheet python project/tracking.py", line 252, in <module>
if mySheet.sheet.cell(thisRow,38).value == 'Y':
File "c:\Users\muddi\AppData\Local\Programs\Python\Python37\lib\site-packages\gspread\models.py", line 381, in cell
params={'valueRenderOption': value_render_option}
File "c:\Users\muddi\AppData\Local\Programs\Python\Python37\lib\site-packages\gspread\models.py", line 110, in values_get
r = self.client.request('get', url, params=params)
File "c:\Users\muddi\AppData\Local\Programs\Python\Python37\lib\site-packages\gspread\client.py", line 79, in request
raise APIError(response)
gspread.exceptions.APIError: {
"error": {
"code": 429,
"message": "Insufficient tokens for quota 'ReadGroup' and limit 'USER-100s' of service 'sheets.googleapis.com' for consumer 'project_number:534908720134'.",
"status": "RESOURCE_EXHAUSTED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developer console API key",
"url": "https://console.developers.google.com/project/534908720134/apiui/credential"
}
]
}
]
}
}
I have been using this code for the past 6 months. I have not had any issues with API calls, which is the reason this is not in stackoverflow. Please note that there is not traceback for 0.6.2 because it just crashes the terminal.
Issue Analytics
- State:
- Created 5 years ago
- Comments:13
Top GitHub Comments
Source: https://developers.google.com/sheets/api/limits
I just sidestepped this by using a semantic statement on the the
get_all_values()
output, instead of usingcol_values()
.For example, if you want the values of the 3rd column in a sheet:
This cuts down on requests a lot.