Python Google Sheets API Permission Issues

I’m trying to connect to Google Sheets using Python but getting permission errors. I followed a tutorial and set up everything correctly. My authentication works fine but when I try to open a spreadsheet I get an error about insufficient authentication scopes.

import gspread
from oauth2client.service_account import ServiceAccountCredentials

api_scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('service_key.json', api_scope)
gspread_client = gspread.authorize(credentials)

worksheet = gspread_client.open("Sales Data").sheet1

The error message says:

APIError: {
"error": {
  "errors": [{
      "domain": "global",
      "reason": "insufficientPermissions",
      "message": "Insufficient Permission: Request had insufficient authentication scopes."
    }],
  "code": 403,
  "message": "Insufficient Permission: Request had insufficient authentication scopes."
 }
}

How can I fix this permission problem? What scopes should I be using?

Your Google Sheets API scope is deprecated and doesn’t have enough permissions. I encountered this same issue last year on a data project. The https://spreadsheets.google.com/feeds scope won’t work with modern gspread operations. Change your api_scope to https://www.googleapis.com/auth/spreadsheets for full read/write access. If you require just read access, use https://www.googleapis.com/auth/spreadsheets.readonly instead. Additionally, ensure that your service account has access to the spreadsheet by sharing the sheet with the service account email found in your service_key.json file. This prevented me from proceeding initially—authentication succeeded, but I had neglected to grant the service account permission for the specific sheets.

The scope issue comes from using an outdated API endpoint that Google’s been phasing out. I hit this exact problem migrating a project last month. Update your scope to https://www.googleapis.com/auth/spreadsheets, but also check that your service account credentials file has the right client email. Sometimes auth looks successful but fails at the resource level because the spreadsheet isn’t shared with that specific service account email. Grab the client_email from your service_key.json and make sure you’ve shared your “Sales Data” spreadsheet with that email through normal Google Sheets sharing. Without this step, even the right scopes won’t get you access to your spreadsheet.

had the same prob a few months back. ur using the old oauth2client, which is deprecated. switch to google-auth and use the https://www.googleapis.com/auth/drive scope along with ur sheets scope. also, share the spreadsheet with ur service account email.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.