【发布时间】:2015-09-05 14:27:44
【问题描述】:
我想使用 gspread,由于客户端身份验证已过时,我正在尝试使用 Oauth2。我是 gspread 和 Oauth2 的新手。
拼凑from this basic Oauth2 example和the gspread documentation我有最基本的登录功能。
import gspread
from oauth2client.client import OAuth2WebServerFlow
CLIENT_ID = 'my id'
CLIENT_SECRET = 'my secret key'
flow = OAuth2WebServerFlow(client_id= CLIENT_ID,
client_secret= CLIENT_SECRET,
scope='https://docs.google.com/spreadsheets/',
redirect_uri='http://localhost:80')
gc = gspread.authorize(flow)
问题是我收到此错误。
TypeError: 'OAuth2WebServerFlow' 对象不支持索引
从大的
C:\Python34\lib\site-packages\gspread\client.py:73:警告: ClientLogin 已弃用: https://developers.google.com/identity/protocols/AuthForInstalledApps?csw=1
Authorization with email and password will stop working on April 20, 2015. Please use oAuth2 authorization instead: http://gspread.readthedocs.org/en/latest/oauth2.html""",警告) 回溯(最近一次通话最后): 文件“C:\Users\family\Desktop\mygspread.py”,第 13 行,在 gc = gspread.authorize(流) 文件“C:\Python34\lib\site-packages\gspread\client.py”,第 335 行,在授权中 client.login() 文件“C:\Python34\lib\site-packages\gspread\client.py”,第 105 行,登录 数据 = {'Email': self.auth[0], TypeError: 'OAuth2WebServerFlow' 对象不支持索引
由于两者都是官方脚本 - 一个来自 google,另一个来自 burnash,我不确定要更改什么。我知道这个问题很基础,但是如何使用 Python 3.4 登录?
【问题讨论】:
-
基本上谷歌已经正式宣布“从 2015 年 4 月 20 日起,访问任何谷歌 API 的唯一方法是通过 OAUTH 2.0” 以前,我们可以通过提供我们的电子邮件和密码来访问。目前已贬值。所以,选择 Burnash 的那个。
标签: python-3.x oauth-2.0 gspread