4

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)
Tanaike
  • 181,128
  • 11
  • 97
  • 165
Tirterra
  • 579
  • 2
  • 4
  • 14
  • 1
    In your case, when the Spreadsheet ID is used like `sheet = client.open_by_key("###")` instead of `client.open("GuildTaxes")`, what result will you retrieve? – Tanaike Aug 20 '20 at 22:36

1 Answers1

16

I found the answer! After 2 hours, the scope in TechWithTim's video doesn't work for me, so if you stumble 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.

Ram Narasimhan
  • 22,341
  • 5
  • 49
  • 55
Tirterra
  • 579
  • 2
  • 4
  • 14