“不允许不安全的 HTTP 请求。使用 HTTPS。”当尝试使用 gdata 2.0.16 python 库检索用户时
我正在尝试使用 gdata 配置 api 文档中找到的以下代码来检索用户。我正在为 django 1.3
应用程序尝试此操作,在 python2.7
中运行 gdata-2.0.16
:
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')
出于隐私考虑,我更改了实际的username 为 '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 的任何内容。我缺少什么?
I'm trying to retrieve a user with the following code found in the gdata provisioning api documentation. I'm attempting this for a django 1.3
app, running gdata-2.0.16
in 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')
For privacy, I changed the actual username to 'user_name'
, but that's the general gist of the code.
When the interpreter gets to the last line in the code above, I get the following error:
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>
I can't find anything in the documentation on using HTTPS instead of HTTP. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
创建客户端对象后,执行
client.ssl = True
。这将导致 gdata api 使用安全连接。After creating the client object, execute
client.ssl = True
. This will cause the gdata api to use a secure connection.尝试附加到 评论 3 的补丁问题 Marketplace 中的 AppsService - SSL 问题
Try patch attached to Comment 3 of the issue AppsService in Marketplace - SSL issues
在客户端身份验证后添加行有帮助
client.ssl=True。
adding the line after the client authentication helps
client.ssl=True.