我想使用gspread,並且由於客戶端身份驗證已過時,因此我嘗試使用Oauth2。我是新手gspread & Oauth2。Python 3.4上的Gspread&Oauth2 - Oauth不支持索引
拼在一起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' object does not support indexing
從大
C:\Python34\lib\site-packages\gspread\client.py:73: Warning: ClientLogin is deprecated: 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
""", Warning) Traceback (most recent call last): File "C:\Users\family\Desktop\mygspread.py", line 13, in gc = gspread.authorize(flow) File "C:\Python34\lib\site-packages\gspread\client.py", line 335, in authorize client.login() File "C:\Python34\lib\site-packages\gspread\client.py", line 105, in login data = {'Email': self.auth[0], TypeError: 'OAuth2WebServerFlow' object does not support indexing
既然都是官方文字 - 一個由谷歌和burnash其他的,我不知道什麼改變。我知道這個問題是基本的,但我如何使用Python 3.4登錄?
基本上谷歌已經發表正式聲明說:「從2015年4月20日,訪問任何谷歌API的唯一途徑是通過OAuth 2.0用戶」 以前,我們可以通過訪問給我們的電子郵件和密碼。目前它已折舊。所以,與Burnash一起去吧。 – Jordon