【发布时间】:2016-06-14 12:28:03
【问题描述】:
我正在尝试运行https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-py 此处提供的示例以进行授权。
我从 SO 中的其他问题中注意到 (ImportError: cannot import name SignedJwtAssertionCredentials) SignedJwtAssertionCredentials 已被删除,因此无法导入。
所以,我开始关注 GitHub 页面 (https://github.com/google/oauth2client/issues/401) 和 StackOverflow 上提供的解决方案。到目前为止,没有任何效果,我仍然看到同样的错误。以下是我的代码。
import argparse
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
import httplib2
from oauth2client import client
from oauth2client import file
from oauth2client import tools
而且,这是我在运行上述代码时收到的错误。
ImportError: cannot import name ServiceAccountCredentials
由于我是这个领域的新手,我尝试对OAuth 的两个版本(2.0.0 和 1.5.2)都这样做。安装pyopenssl后我也试过了,还是失败了。
【问题讨论】:
-
你能包含
import oauth2client; oauth2client.__version__的输出吗? -
import oauth2clientoauth2client.__version__?Type: str String form: 2.0.0-post1 Length: 11 Docstring: str(object='') -> stringReturn a nice string representation of the object. If the argument is a string, the return value is the same object. -
问题现在似乎已经解决了。我只是在几个小时后尝试了它,它起作用了。
标签: python oauth-2.0 google-api google-oauth google-analytics-api