2012-02-02 29 views
5

我试图用gdata provisioning api documentation中找到的以下代码检索用户。我试图这样一个django 1.3的应用程序,在运行python2.7gdata-2.0.16“不允许不安全的HTTP请求,请使用HTTPS”。当试图用gdata 2.0.16 python库检索用户

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此文档中发现任何东西。我错过了什么?

回答

8

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

0

添加行客户端身份验证有助于 client.ssl =真之后。