Google Auth2更新后,Gspread保持活跃 [英] Gspread keep alive after update google auth2
本文介绍了Google Auth2更新后,Gspread保持活跃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有几个示例可以保持与Google电子表格的连接保持活动状态" 但是我发现的所有内容都是基于旧的" Google登录系统,自2015年4月起不再可用
There are several examples for 'keep the connection with google spreadsheet alive' But all I found are based on the 'old' Google Sign-In system which isn't work anymore since april 2015
使用OAuth 2.0使与googlespreadsheet的连接保持活动状态的正确方法是什么
What is the proper methode to keep the connection with googlespreadsheet alive using OAuth 2.0
我已经尝试过
import gspread
from oauth2client.service_account import ServiceAccountCredentials
headers = gspread.httpsession.HTTPSession(headers={'Connection':'Keep-Alive'}) #Allows a persistant connection.
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('Apps Script Execution API.json', scope)
c = gspread.authorize(auth=credentials,http_session=headers)
结果: c = gspread.authorize(auth =凭据,http_session =标题) TypeError:authorize()得到了意外的关键字参数"auth"
result: c = gspread.authorize(auth=credentials,http_session=headers) TypeError: authorize() got an unexpected keyword argument 'auth'
推荐答案
您的问题的最新答案是:
A late answer to your question is:
import gspread
from gspread.httpsession import HTTPSession
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
key_name = 'something.json'
credentials = ServiceAccountCredentials.from_json_keyfile_name(key_name, scope)
#gc = gspread.authorize(credentials) doesn't have a http_session kwarg
http_session = HTTPSession(headers={'Connection':'Keep-Alive'})
gc = gspread.Client(credentials, http_session)
gc.login()
ss = gc.open("Sachibondu-MasonryVaults")
这篇关于Google Auth2更新后,Gspread保持活跃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文