pythonopenid和Google Apps联合登录错误

2024-04-19 11:32:08 发布

您现在位置:Python中文网/ 问答频道 /正文

更新

我设法让它正常工作,尽管我不太确定为什么;)python openid似乎使用POST请求来发出openid mode=associate,但出于某种原因,Google不喜欢这样做。当我修补python openid以使用GET请求时,一切正常。我会继续我的调查和更新这个帖子,当我有更多的信息。下面是我找零钱的差额。在

--- python-openid-2.2.1.orig/openid/consumer/consumer.py
+++ python-openid-2.2.1/openid/consumer/consumer.py
@@ -229,6 +229,20 @@
     # Process response in separate function that can be shared by async code.
     return _httpResponseToMessage(resp, server_url)

+def makeKVGet(request_message, server_url):
+    """Make a Direct Request to an OpenID Provider and return the
+    result as a Message object.
+
+    @raises openid.fetchers.HTTPFetchingError: if an error is
+        encountered in making the HTTP post.
+
+    @rtype: L{openid.message.Message}
+    """
+    # XXX: TESTME
+    resp = fetchers.fetch(request_message.toURL(server_url))
+
+    # Process response in separate function that can be shared by async code.
+    return _httpResponseToMessage(resp, server_url)

 def _httpResponseToMessage(response, server_url):
     """Adapt a POST response to a Message.
@@ -682,6 +696,7 @@
         return True

     _makeKVPost = staticmethod(makeKVPost)
+    _makeKVGet = staticmethod(makeKVGet)

     def _checkSetupNeeded(self, message):
         """Check an id_res message to see if it is a
@@ -1258,7 +1273,7 @@
             endpoint, assoc_type, session_type)

         try:
-            response = self._makeKVPost(args, endpoint.server_url)
+            response = self._makeKVGet(args, endpoint.server_url)
         except fetchers.HTTPFetchingError, why:
             oidutil.log('openid.associate request failed: %s' % (why[0],))
             return None

老问题,为上下文保留

我一直在拼命地让trac-authopenid插件工作,但是没有成功。在

我们在工作中使用googleapps Premier,所以我试图让openid auth使用它。我想我已经设置了所有需要的东西(XRD和类似的),我已经让它可以很好地与apache2+mod-auth-openid一起工作,也可以在其他网站上使用它(例如)。在

但我似乎无法让它与trac authopenid一起工作。我被重定向(通过一个表单发布,而不是像往常一样重定向)到Google,在那里我可以登录,但是当我返回插件时,插件只是声明验证失败了。在

如果我打开调试日志,我会得到这个(我已经用example.com网站)在

^{pr2}$

我试着直接针对python-openid库编写一些代码,以缩小它的范围,但我还是一窍不通。我已经能够用以下代码片段重现错误:

from openid.store.memstore import MemoryStore
from openid.consumer import consumer

session = { 'id' : 'foobar' }
store = MemoryStore()
consumer = consumer.Consumer(session, store)
consumer.begin('https://www.google.com/accounts/o8/site-xrds?hd=example.com')

持续输出

kvToSeq warning: Line 1 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Not Implemented</H1>\n<H2>Error 501</H2>\n</BODY>\n</HTML>\n'
kvToSeq warning: Line 2 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Not Implemented</H1>\n<H2>Error 501</H2>\n</BODY>\n</HTML>\n'
kvToSeq warning: Line 3 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Not Implemented</H1>\n<H2>Error 501</H2>\n</BODY>\n</HTML>\n'
... snip ...
openid.associate request failed: bad status code from server https://www.google.com/a/example.com/o8/ud?be=o8: 501

某些版本号:

Python 2.6.2
trac-authopenid 0.1.6
python-openid 2.2.1

我完全不知所措,我真的需要一些帮助。在


Tags: urlmessagereturnserverconsumertitleresponsehtml
2条回答

您提到了在Python openid中使用Python2.6.2。自述文件的Requirements部分当前只列出python2.3、2.4或2.5。很高兴听到你成功了。在

好吧。我没有Apps帐户,因此无法测试登录,但我可以使用python openid 2.2.4成功地与Apps域关联。这里有一个用于发出关联请求的小调试工具:http://gist.github.com/288560

你的补丁不应该有固定的东西;associate requests are always POSTs。而且Ruby库也总是发布,所以除非rpxnow做了一些不寻常的修改,否则当python openid在这里失败时,rpxnow不应该工作。在

我本来想问你关于安装中的openid.store,但是如果你用MemoryStore的最小示例复制了它,那就不是问题了。在

我想我唯一能给你的就是建议你向谷歌应用的客户支持咨询。在

相关问题 更多 >