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

发布于 2025-01-02 11:59:41 字数 1575 浏览 1 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

您的好友蓝忘机已上羡 2025-01-09 11:59:41

创建客户端对象后,执行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.

调妓 2025-01-09 11:59:41

尝试附加到 评论 3 的补丁问题 Marketplace 中的 AppsService - SSL 问题

Try patch attached to Comment 3 of the issue AppsService in Marketplace - SSL issues

只是我以为 2025-01-09 11:59:41

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

adding the line after the client authentication helps
client.ssl=True.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文