python - 尝试使用 GoogleSheet API 打开电子表格时如何修复“google.auth.exceptions.RefreshError: ('No access token in response。”
问题描述
我一步一步地跟着 TechWithTim 的视频(https://www.youtube.com/watch?v=cnPlKLEGR7E)但是当我尝试打开工作表时仍然出现错误。该代码工作正常,直到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)
解决方案
我找到了答案!2 小时后,TechWithTim 视频中的范围对我不起作用,所以如果您遇到同样的问题,请尝试使用这个
scope = [
'https://www.googleapis.com/auth/spreadsheets',
'https://www.googleapis.com/auth/drive'
]
它是默认范围。
推荐阅读
- dart - 在本地获取和存储 json
- go - 为什么 imagemagick 中的 PNG 图像 readimage 和 writeimage 需要很多时间?
- java - Spring Data CouchbaseTemplate 和 setWriteResultChecking
- dataframe - 如何更改熊猫中的索引名称?
- cuda - CUDA 驱动程序 API - 最低驱动程序版本?
- git - 如何禁用 Git 自动检测电子邮件地址?
- powershell - 脚本路径中的 Powershell 空格
- postgresql - 如何提高 Spring Data JPA 性能
- ruby-on-rails - (Rails)将带有初始数据的新模型添加到现有应用程序
- json - Python3 - Json 通过 Rest API 写入值