gspread: gspread.v4.exceptions.APIError - Insufficient Permission

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"
 }
}

About this issue

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

Commits related to this issue

Most upvoted comments

Ok, try to change your scope to the following:

scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']

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"
 }
}

Adding to the scope of the https://www.googleapis.com/auth/drive helped open with the help of open. But the reading of the formulas still gives None.

Adding the extra scope worked for me. Also make sure you have sheets and drive api enabled.