Python Google Sheets Integration Permission Error

I’m trying to connect to Google Sheets using Python but getting a 403 permission error. I set up the authentication with a service account JSON file and used the gspread library. The error says “insufficient authentication scopes” when I try to open my spreadsheet.

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)
gs_client = gspread.authorize(credentials)

workbook = gs_client.open("Data Tracker").sheet1

The last line throws this error:

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

I followed the setup guide and saved the JSON file in the right folder. The scope and credentials work fine but I can’t access the actual sheet. What am I missing here?

Hit this same issue last month. Everyone’s mentioning scope problems, but check if you’ve enabled the Google Sheets API in your Google Cloud Console first. I had the right scopes and service account setup, but still got permission errors because the API wasn’t enabled. Go to APIs & Services, search for Google Sheets API, and turn it on. Also make sure your service account has Editor role in IAM permissions - the default permissions often aren’t enough even when everything else looks correct.

hey, i had that issue too! adding https://www.googleapis.com/auth/drive to your api_scope worked for me. also, double-check if the sheet is shared with the service account email from your json file.

Your scope is outdated. The https://spreadsheets.google.com/feeds endpoint was deprecated ages ago. Switch to the current Google Sheets API scope: https://www.googleapis.com/auth/spreadsheets. I hit the same 403 error migrating an old project - this fixed it instantly. The old feeds scope doesn’t have enough permissions for modern gspread stuff. If you only need read access, use https://www.googleapis.com/auth/spreadsheets.readonly instead - it’s more secure.