2016-04-22 88 views
2

沒有關於「保持與谷歌電子表格的連接活着」 幾個例子但是,所有我發現是基於對「老」谷歌登入系統,這是不是因爲2015年4月工作了上Gspread更新谷歌auth2後存活

什麼是正確的梅索德跟上googlespreadsheet活着使用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_s分裂國家=報頭) 類型錯誤:授權()得到了一個意想不到的關鍵字參數「權威性」

回答

2

逾期回答你的問題是:

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")