Python 如何解决“问题”;google.auth.exceptions.RefreshError:(“响应中没有访问令牌”。“尝试使用GoogleSheet API打开电子表格时。”

Python 如何解决“问题”;google.auth.exceptions.RefreshError:(“响应中没有访问令牌”。“尝试使用GoogleSheet API打开电子表格时。”,python,google-sheets-api,gspread,Python,Google Sheets Api,Gspread,我循序渐进地观看了TechWithTim的视频() 但当我试图打开工作表时,仍然会出错。 代码工作正常,直到sheet=client.open(“GuildTaxes”).sheet1行。 这是我的密码 import gspread from oauth2client.service_account import ServiceAccountCredentials scope = ["https://spreadsheets.google.com/feeds","

我循序渐进地观看了TechWithTim的视频() 但当我试图打开工作表时,仍然会出错。 代码工作正常,直到
sheet=client.open(“GuildTaxes”).sheet1
行。 这是我的密码

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)

我找到了答案!两个小时后,TechWithTim视频中的示波器对我不起作用,所以如果你在同一问题上存根,请尝试使用这个

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

这是默认范围。

在您的情况下,当使用电子表格ID,如
sheet=client.open_by_key(“####”)
而不是
client.open(“GuildTaxes”)
,您将检索到什么结果?