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.

gspread.v4.exceptions.APIError - Insufficient Permission

See original GitHub issue

Hello. After the OS was reinstalled, the script stopped working. gspread 2.0.0 python 2.7.12

code

# -*- coding: utf-8 -*- 
import gspread
from oauth2client.service_account import ServiceAccountCredentials

scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('123.json', scope)
gc = gspread.authorize(credentials)
wks = gc.open("123")

error

Traceback (most recent last call last):
  File "test.py", line 11, in <module>
    wks = gc.open ("123")
  File "/usr/local/lib/python2.7/dist-packages/gspread/v4/client.py", line 103, in open
    self.list_spreadsheet_files ()
  File "/usr/local/lib/python2.7/dist-packages/gspread/v4/client.py", line 80, in list_spreadsheet_files
    r = self.request ('get', url)
  File "/usr/local/lib/python2.7/dist-packages/gspread/v4/client.py", line 73, in request
    raise APIError (response)
gspread.v4.exceptions.APIError: {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "insufficientPermissions",
    "message": "Insufficient Permission"
   }
  ],
  "code": 403,
  "message": "Insufficient Permission"
 }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

110reactions
burnashcommented, Mar 13, 2018

Ok, try to change your scope to the following:

scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']
3reactions
abnd90commented, Mar 13, 2018

I can confirm the exact same issue. I also tried regenerating service api creds.

Traceback (most recent call last):
  File "./main.py", line 94, in <module>
    main()
  File "./main.py", line 81, in main
    sh = gc.open(GSHEET_NAME)
  File "/home/abhinand/dev/pctogs/venv/lib/python3.6/site-packages/gspread/v4/client.py", line 103, in open
    self.list_spreadsheet_files()
  File "/home/abhinand/dev/pctogs/venv/lib/python3.6/site-packages/gspread/v4/client.py", line 80, in list_spreadsheet_files
    r = self.request('get', url)
  File "/home/abhinand/dev/pctogs/venv/lib/python3.6/site-packages/gspread/v4/client.py", line 73, in request
    raise APIError(response)
gspread.v4.exceptions.APIError: {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "insufficientPermissions",
    "message": "Insufficient Permission"
   }
  ],
  "code": 403,
  "message": "Insufficient Permission"
 }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

getting 403 insufficient permission error on gspread v2 ...
... try to amazon linux server it gives insufficent permission error gspread.v4.exceptions.APIError: { "error": { "errors": [ { "domain...
Read more >
python - gspread authentication throwing insufficient permission
when moved same config to linux server on aws its giving 403 insufficient permission error. Pip and python version are same. exception gspread....
Read more >
Python – gspread authentication throwing insufficient permission
Using developers.google.com we created api user and downloaded credentials as json file. Now On my macbook gspread authentication is working fine while ...
Read more >
Client — gspread 5.4.0 documentation
An instance of this class communicates with Google API. Parameters: auth – An OAuth2 credential object. Credential objects created by google-auth. session – ......
Read more >
Setting up Python to Connect to Google Sheets
The issue I was seeing was as follows: gspread.exceptions.APIError: {'errors': [{'domain': ' ...
Read more >

github_iconTop Related Medium Post

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