【发布时间】:2020-02-02 07:57:35
【问题描述】:
我正在尝试创建一个将一些数据发布到 Google 表格电子表格的简单函数。我在 AWS Lambda 中托管这个函数。无论如何,代码看起来有点像这样:
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = [
'https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive'
]
credentials = ServiceAccountCredentials.from_json_keyfile_name(
'my_creds.json', scope
)
gc = gspread.authorize(credentials)
这非常有效,但不幸的是,这个过程非常缓慢。大部分时间似乎都用于授权。所以我的问题是:有没有办法授权和保存授权对象并将其重新用于接下来的几个请求?一旦有效期结束,该功能可以再次对其进行授权。非常感谢任何帮助!
【问题讨论】:
标签: python google-sheets gspread