0

我完全无法使用 Google API Python 客户端。我正在尝试做一件非常简单的事情。我在 Google Apps Marketplace 中添加了一个应用程序,并已授权用户访问我的域。

现在,我想配置用户。我正在尝试在没有最终用户的情况下访问 Admin SDK。

我使用官方示例代码作为模板 - https://code.google.com/p/google-api-python-client/source/browse/samples/service_account/tasks.py

我收到以下错误:/test-oauth/ [('asn1 encoding routines', 'ASN1_D2I_READ_BIO', 'not enough data')]

它发生在 Google oauth2 客户端代码中 - /oauth2client/crypt.py in from_string,第 131 行

我正在使用 Python 2.7、Django 1.5.2 和 Google Python API Client 1.2(我添加了 pyOpenSSL 和 pyCrypto)。这是我安装的:

分发(0.6.36)

lxml (3.2.3)

MySQL-python (1.2.4)

麻木(1.7.1)

点 (1.4)

pycrypto (2.6)

pyOpenSSL (0.11)

scikit-learn (0.14.1)

安装工具 (0.9.8)

wsgiref (0.1.2)

这是代码:

def get_google_api_data(请求):

# The 2-LO authorization section
credentials = SignedJwtAssertionCredentials(settings.SOCIAL_AUTH_GOOGLE_OAUTH2_KEY,
                                            settings.SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET,
                   scope='https://www.googleapis.com/auth/admin.directory.user.readonly')
http = httplib2.Http()
http = credentials.authorize(http)

# Initializing the Tasks API service
service = build('admin', 'directory_v1', http=http)

return

谁能告诉我为什么我无法连接到该服务?

多米尼克

4

1 回答 1

1

对于初学者: 2 legged OAuth != OAuth2
这不是您应该使用 Admin SDK API 的方式。请阅读本文以了解 OAuth2。

2 Legged OAuth auth已弃用

于 2013-09-12T10:53:33.277 回答