question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Insufficient tokens for quota 'ReadGroup' and limit 'USER-100s' of service

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:13

github_iconTop GitHub Comments

2reactions
amosbastiancommented, Aug 20, 2018

This version of the Google Sheets API has a limit of 500 requests per 100 seconds per project, and 100 requests per 100 seconds per user. Limits for reads and writes are tracked separately. There is no daily usage limit.

To view or change usage limits for your project, or to request an increase to your quota, do the following:

  1. If you don’t already have a billing account for your project, then create one.
  2. Visit the Enabled APIs page of the API library in the API Console, and select an API from the list.
  3. To view and change quota-related settings, select Quotas. To view usage statistics, select Usage.

Source: https://developers.google.com/sheets/api/limits

1reaction
muddi900commented, May 15, 2019

I just sidestepped this by using a semantic statement on the the get_all_values() output, instead of using col_values().

For example, if you want the values of the 3rd column in a sheet:

x= myworkbook.mysheet.get_all_values()
column  = [i[2] for i in x]

This cuts down on requests a lot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Insufficient tokens for quota 'administrator' and limit ...
In the Quotas page, under "Quota type," select "All quotas," then under "Service" select "Google Cloud Pub/Sub API." The quota you want to ......
Read more >
Details about "rateLimitExceeded" errors - Google Groups
"message" : "Insufficient tokens for quota 'ReadGroup' and limit 'USER-100s' of service 'sheets.googleapis.com' for consumer 'project_number:1234567890'.",.
Read more >
Update Google Sheet with Python
I have to update three columns namely A,B & C of which the value start row is from 4th row onwards. So basically...
Read more >
Error 429: Insufficient Tokens (Defaultgroupuser-100S) What ...
APIError: { error: { code: 429 message: Insufficient tokens for quota 'ReadGroup' and limit 'USER100s' of service. HTTP Status Code 429: The user...
Read more >
Ok, here is the story about how Balkans can change your code ...
So you have to go deeper and found this: "Insufficient tokens for quota 'ReadGroup' and limit 'USER-100s' of service 'sheets.googleapis.com' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found