Python gmail api: 建立安全连接时出错
Python gmail api: Error while establishing secure connection
我试图让我的程序与 Gmail 一起工作 API
我按照 google 在 Youtube 上的官方教程中给出的说明进行操作:https://www.youtube.com/watch?v=L6hQCgxgzLI 相应地
这是我的代码(仅包括授权):
from apiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
SCOPES = 'https://www.googleapis.com/auth/gmail.readonly'
CLIENT_SECRET = 'client_secret.json'
store = file.Storage('storage.json')
creds = store.get()
if creds is None or creds.invalid:
flow = client.flow_from_clientsecrets(CLIENT_SECRET, SCOPES)
creds = tools.run(flow, store)
GMAIL = build('gmail', 'v1', http=creds.authorize(Http()))
但是当我 运行 代码时,会发生以下情况
AttributeError: module 'oauth2client.tools' has no attribute 'run'
我哪里错了?
https://developers.google.com/gmail/api/quickstart/python#step_3_set_up_the_sample
如果标志:
凭据 = tools.run_flow(流、存储、标志)
else: # 只需要与 Python 2.6
兼容
凭据 = tools.run(流、存储)
从 tools.run() 迁移到 tools.run_flow()
这个迷你教程 slash 迁移指南 slash PSA(public 服务公告)面向 Python 使用 Google API 客户端库的开发人员(从他们的 Python 应用程序)当前正在调用 oauth2client.tools.run(),并可能收到弃用警告 and/or 考虑迁移到 oauth2client.tools.run_flow(),它的替代品。
更新(2016 年 1 月):运行() 函数本身已于 2015 年 8 月从客户端库中删除,因此如果您在该日期或之后使用任何版本,对 [=27 的任何调用=]() 来自您的应用程序代码将引发异常。这篇博文是为那些处于这种情况并需要立即迁移的人创建的。
http://wescpy.blogspot.fr/2015/04/migrating-from-toolsrun-to-toolsrunflow.html
我试图让我的程序与 Gmail 一起工作 API
我按照 google 在 Youtube 上的官方教程中给出的说明进行操作:https://www.youtube.com/watch?v=L6hQCgxgzLI 相应地
这是我的代码(仅包括授权):
from apiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
SCOPES = 'https://www.googleapis.com/auth/gmail.readonly'
CLIENT_SECRET = 'client_secret.json'
store = file.Storage('storage.json')
creds = store.get()
if creds is None or creds.invalid:
flow = client.flow_from_clientsecrets(CLIENT_SECRET, SCOPES)
creds = tools.run(flow, store)
GMAIL = build('gmail', 'v1', http=creds.authorize(Http()))
但是当我 运行 代码时,会发生以下情况
AttributeError: module 'oauth2client.tools' has no attribute 'run'
我哪里错了?
https://developers.google.com/gmail/api/quickstart/python#step_3_set_up_the_sample
如果标志:
凭据 = tools.run_flow(流、存储、标志)
else: # 只需要与 Python 2.6
兼容凭据 = tools.run(流、存储)
从 tools.run() 迁移到 tools.run_flow() 这个迷你教程 slash 迁移指南 slash PSA(public 服务公告)面向 Python 使用 Google API 客户端库的开发人员(从他们的 Python 应用程序)当前正在调用 oauth2client.tools.run(),并可能收到弃用警告 and/or 考虑迁移到 oauth2client.tools.run_flow(),它的替代品。
更新(2016 年 1 月):运行() 函数本身已于 2015 年 8 月从客户端库中删除,因此如果您在该日期或之后使用任何版本,对 [=27 的任何调用=]() 来自您的应用程序代码将引发异常。这篇博文是为那些处于这种情况并需要立即迁移的人创建的。
http://wescpy.blogspot.fr/2015/04/migrating-from-toolsrun-to-toolsrunflow.html