【问题标题】:python gspread authorize oauth2 credentialspython gspread 授权 oauth2 凭据
【发布时间】:2014-10-21 00:54:55
【问题描述】:

如何让 gspread 使用我的 oauth 凭据?我对 http 响应 gspread.httpsession.HTTPError 有错误 :( 谁能告诉我我的代码有什么问题?

import datetime
import gspread
import json
import MySQLdb
from oauth2client.client import OAuth2Credentials


# Get access token from database
data = json.loads(row['access_token'])
credentials = OAuth2Credentials(
    data['access_token'],
    "1*************************k.apps.googleusercontent.com",
    "9t*****************W",
    data['refresh_token'],
    datetime.datetime.now(),
    "https://accounts.google.com/o/oauth2/token",
    'user-agent'
)

gc = gspread.authorize(credentials)
wks = gc.open_by_key('1*****************W')

其中行包含来自数据库的数据(它具有由 google oauth 返回的访问令牌)? m(_ _)m

【问题讨论】:

    标签: python oauth gspread


    【解决方案1】:

    我在使用 Oauth2Credentials 进行身份验证时也遇到了麻烦。我的建议是使用googles Oauth2 工作流程来创建凭据。此外,请确保使用“https://spreadsheets.google.com/feeds”作为凭据的范围。

    我目前正在使用此流程,并且我的通话工作正常。

    【讨论】:

      猜你喜欢
      • 2019-01-13
      • 2015-07-03
      • 2021-04-24
      • 1970-01-01
      • 1970-01-01
      • 2015-08-19
      • 1970-01-01
      • 1970-01-01
      • 2018-01-22
      相关资源
      最近更新 更多