【发布时间】:2018-04-14 07:33:51
【问题描述】:
我正在尝试使用 OAuth2 和 gspread 来使用 Python 来操作 Google 表格。但是,我一直遇到这个错误:
invalid_scope:https://spreadsheets.google.com/feeds 不是有效的受众字符串。
最初,我将范围作为一个列表,但是,我在 StackOverflow 上看到另一个答案,说范围应该是一个以空格分隔的字符串。我试着改过,但错误仍然发生。
这是我的代码:
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ' '.join(['https://spreadsheets.google.com/feeds', 'https://googleapis.com/auth/drive'])
credentials = ServiceAccountCredentials.from_json_keyfile_name("SpreadsheetExample-bec536232207.json", 'https://spreadsheets.google.com/feeds https://googleapis.com/auth/drive')
gc = gspread.authorize(credentials)
wks = gc.open("test").sheet1
print(wks.get_all_records())`
【问题讨论】:
标签: python google-drive-api google-sheets-api google-oauth gspread