尝试使用GoogleSheet API打开电子表格时,如何解决“ google.auth.exceptions.RefreshError :'无访问令牌响应”

问题描述

我逐步跟踪了TechWithTim的视频(https://www.youtube.com/watch?v=cnPlKLEGR7E) 但是尝试打开工作表时仍然出现错误。 该代码sheet = client.open("GuildTaxes").sheet1行之前可以正常工作。 这是我的代码

@H_502_4@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'
]

这是默认范围。