【发布时间】:2016-07-12 17:27:46
【问题描述】:
我试图使用 oauth2client 和 gspread 在 googlesheet 上进行操作,但我遇到的问题是,当使用 oauth2client 时,它需要一个范围字段。我不知道范围是什么。以下是oauth2client的使用代码。
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('gspread-april-2cd … ba4.json', scope)
gc = gspread.authorize(credentials)
wks = gc.open("Where is the money Lebowski?").sheet1
【问题讨论】:
-
您无法打开电子表格吗?或者您只是想知道范围是什么?
-
@Burnash 我弄清楚了范围,但我随后使用了 open_with_url 并直接复制了我的电子表格的 url,当我尝试我的代码时它显示“没有找到电子表格”。我创建的电子表格来自我创建 Google 项目的同一个帐户(或 API,我忘了它叫什么)
-
您是否在 gspread-april-2cd...ba4.json 中与
client_email共享了电子表格 -
那个 gspread-xxxx.json 文件是我创建项目时下载的文件,对吧? client_email 应该是我创建项目的 Google 帐户?
-
是的,gspread-xxxx.json 是您在创建凭据时下载的文件。
client_email是此文件中的参数,而不是 google 帐户。
标签: oauth google-oauth google-spreadsheet-api gspread oauth2client