How to fix the "google.auth.exceptions.RefreshError: ('No access token in response." when trying to open a spreadsheet using GoogleSheet API

Viewed 9153

I followed the video from TechWithTim step by step (https://www.youtube.com/watch?v=cnPlKLEGR7E) but I am still getting an error when I try to open the sheet. The code works fine until sheet = client.open("GuildTaxes").sheet1 line. Here is my code.

import gspread
from oauth2client.service_account import ServiceAccountCredentials

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

creds = ServiceAccountCredentials.from_json_keyfile_name("GuildTaxes-9ba4508be840.json", scope)

client = gspread.authorize(creds)

sheet = client.open("GuildTaxes").sheet1

data = sheet.get_all_records()

print(data)
1 Answers

I found the answer !After 2 hours, the scope in TechWithTim's video doesn't work for me, so if you stubble upon the same issue try using this one

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

It is the default scope.

Related