Python 谷歌电子表格api不使用OAuth2?
我正在尝试向google电子表格API和我找到的所有示例发出授权请求,请求来自用户的电子邮件和密码Python 谷歌电子表格api不使用OAuth2?,python,google-sheets,google-spreadsheet-api,Python,Google Sheets,Google Spreadsheet Api,我正在尝试向google电子表格API和我找到的所有示例发出授权请求,请求来自用户的电子邮件和密码 这个问题是用Google实现的OAuth2协议解决的。我已经完成了OAuth2过程,我有一个有效的access_令牌,我使用它与Google Drive顺利交互: access_token = get_access_token() # external function user_agent = request.META['HTTP_USER_AGENT'] credentials =
access_token = get_access_token() # external function
user_agent = request.META['HTTP_USER_AGENT']
credentials = AccessTokenCredentials(access_token, user_agent)
http = httplib2.Http()
http = credentials.authorize(http)
service = build('drive', 'v2', http)
service.files().copy(fileId=k, body=dict(title="Copia")).execute() # this works!
但我无法找到一种使用access_令牌与电子表格API交互的方法。它仍然使用电子邮件和密码登录吗
谢谢
顺便说一句,我正在使用PythonGData包,如果你有一个很好的参考资料,请告诉我!:) 所以,如果您已经有了一个访问令牌(可能是您自己通过Oauth2协议获得的,就像我一样)。您可以与google电子表格api交互,将AuthSubToken的实例传递给电子表格客户端的方法
from gdata.gauth import AuthSubToken
from gdata.spreadsheets.client import SpreadsheetsClient
atok = AuthSubToken(token_string=get_access_token()) # acess token via protocol
data = SpreadsheetsClient().get_worksheets(key, auth_token=atok)