“不允许使用不安全的HTTP请求。请使用HTTPS。”当试图用gdata 2.0.16 python库检索用户时

时间:2012-02-02 18:41:44

标签: python https gdata

我正在尝试使用gdata provisioning api documentation中的以下代码检索用户。我正在尝试使用django 1.3应用,在gdata-2.0.16中运行python2.7

from gdata.apps import client
from myapp import settings
client = client.AppsClient(domain=settings.GOOGLE_ADMIN_DOMAIN)
client.ClientLogin(email=settings.GOOGLE_ADMIN_EMAIL, password=settings.GOOGLE_ADMIN_PASSWORD, source='apps')
user_account = client.RetrieveUser('user_name')

为保护隐私,我将实际用户名更改为'user_name',但这是代码的一般要点。

当解释器到达上面代码中的最后一行时,我收到以下错误:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/gdata/apps/client.py", line 182, in RetrieveNickname
    return self.GetEntry(uri, desired_class=gdata.apps.data.NicknameEntry)
  File "/usr/local/lib/python2.7/dist-packages/gdata/client.py", line 652, in get_entry
    desired_class=desired_class, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/gdata/client.py", line 319, in request
    RequestError)
RequestError: Server responded with: 403, <HTML>
<HEAD>
<TITLE>Insecure HTTP requests not permitted.  Use HTTPS.</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Insecure HTTP requests not permitted.  Use HTTPS.</H1>
<H2>Error 403</H2>
</BODY>
</HTML>

我在文档中找不到使用HTTPS而不是HTTP的任何内容。我错过了什么?

3 个答案:

答案 0 :(得分:8)

创建客户端对象后,执行client.ssl = True。这将导致gdata api使用安全连接。

答案 1 :(得分:0)

尝试附加到问题的Comment 3的补丁 AppsService中的AppsService - SSL问题

答案 2 :(得分:0)

在客户端身份验证帮助后添加该行 client.ssl =真。