更新
尽管我不太确定为什么,但我设法让它工作了;) 似乎 python-openid 使用 POST 请求来发出 openid mode=associate 并且出于某种原因谷歌不喜欢那样。当我修补 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 @@
# 在异步代码共享的单独函数中处理响应。
返回 _httpResponseToMessage(resp, server_url)
+def makeKVGet(request_message, server_url):
+ """向 OpenID 提供者直接请求并返回
+ 结果作为消息对象。
+
+ @raises openid.fetchers.HTTPFetchingError:如果出现错误
+ 在制作 HTTP 帖子时遇到。
+
+ @rtype: L{openid.message.Message}
+ """
+ # XXX: 测试
+ resp = fetchers.fetch(request_message.toURL(server_url))
+
+ # 在可以由异步代码共享的单独函数中处理响应。
+ 返回 _httpResponseToMessage(resp, server_url)
def _httpResponseToMessage(response, server_url):
"""使 POST 响应适应消息。
@@ -682,6 +696,7 @@
返回真
_makeKVPost = 静态方法(makeKVPost)
+ _makeKVGet = 静态方法(makeKVGet)
def _checkSetupNeeded(自我,消息):
"""检查一个 id_res 消息,看它是否是一个
@@ -1258,7 +1273,7 @@
端点、关联类型、会话类型)
尝试:
- 响应 = self._makeKVPost(args, endpoint.server_url)
+ 响应 = self._makeKVGet(args, endpoint.server_url)
除了 fetchers.HTTPFetchingError,为什么:
oidutil.log('openid.associate 请求失败: %s' % (why[0],))
返回无
老问题,保留上下文
我一直在拼命想让trac-authopenid插件工作,但没有运气。
我们在工作中使用 Google Apps Premier,所以我试图让 openid auth 使用它。我想我已经设置了所有必需的东西(XRDS 等),就谷歌而言,我已经让它与 apache2 + mod-auth-openid以及在其他网站上使用它(SO for例子)。
但我似乎无法让它与 trac-authopenid 一起使用。我被重定向(通过表单帖子,而不是像往常一样的重定向)到我登录的谷歌,但是当我返回插件时,只是表明验证失败。
如果我打开调试日志,我会得到这个(我用 example.com 替换了我们的域名)
2010-01-27 12:21:15,811 Trac[authopenid] DEBUG: beginning OpenID authentication.
2010-01-27 12:21:16,866 Trac[authopenid] DEBUG: kvToSeq warning: Line 1 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n
2010-01-27 12:21:16,866 Trac[authopenid] DEBUG: kvToSeq warning: Line 2 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n
2010-01-27 12:21:16,866 Trac[authopenid] DEBUG: kvToSeq warning: Line 3 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n
... snipped, repeats until line 9...
2010-01-27 12:21:16,867 Trac[authopenid] DEBUG: openid.associate request failed: bad status code from server https://www.google.com/a/example.com/o8/ud?be=
2010-01-27 12:21:16,868 Trac[authopenid] DEBUG: _get_trust_root href: /trac
2010-01-27 12:21:16,868 Trac[authopenid] DEBUG: _get_trust_root abs_href: https://developer.example.com/trac
2010-01-27 12:21:16,868 Trac[authopenid] DEBUG: _get_trust_root href: /trac
2010-01-27 12:21:16,868 Trac[authopenid] DEBUG: _get_trust_root abs_href: https://developer.example.com/trac
2010-01-27 12:21:16,869 Trac[authopenid] DEBUG: Generated checkid_setup request to https://www.google.com/a/example.com/o8/ud?be=o8 using stateless mode.
2010-01-27 12:21:18,068 Trac[main] DEBUG: Dispatching <Request "GET u'/openidprocess'">
2010-01-27 12:21:18,075 Trac[session] DEBUG: Retrieving session for ID '25a842642693232301aad341'
2010-01-27 12:21:18,078 Trac[authopenid] DEBUG: Error attempting to use stored discovery information: <openid.consumer.consumer.TypeURIMismatch: Required ty
2010-01-27 12:21:18,078 Trac[authopenid] DEBUG: Attempting discovery to verify endpoint
2010-01-27 12:21:18,078 Trac[authopenid] DEBUG: Performing discovery on http://example.com/openid?id=113663311178245814720
2010-01-27 12:21:18,121 Trac[authopenid] DEBUG: Received id_res response from https://www.google.com/a/example.com/o8/ud?be=o8 using association AOQobUefon
2010-01-27 12:21:18,121 Trac[authopenid] DEBUG: Using OpenID check_authentication
2010-01-27 12:21:18,121 Trac[authopenid] DEBUG: op_endpoint
2010-01-27 12:21:18,121 Trac[authopenid] DEBUG: claimed_id
2010-01-27 12:21:18,121 Trac[authopenid] DEBUG: identity
2010-01-27 12:21:18,122 Trac[authopenid] DEBUG: return_to
2010-01-27 12:21:18,122 Trac[authopenid] DEBUG: response_nonce
2010-01-27 12:21:18,122 Trac[authopenid] DEBUG: assoc_handle
2010-01-27 12:21:18,576 Trac[authopenid] DEBUG: kvToSeq warning: Line 1 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n
2010-01-27 12:21:18,577 Trac[authopenid] DEBUG: kvToSeq warning: Line 2 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n
2010-01-27 12:21:18,577 Trac[authopenid] DEBUG: kvToSeq warning: Line 3 does not contain a colon: '<HTML>\n<HEAD>\n<TITLE>Not Implemented</TITLE>\n</HEAD>\n
... snipped, repeats until line 9...
2010-01-27 12:21:18,578 Trac[authopenid] DEBUG: check_authentication failed: bad status code from server https://www.google.com/a/example.com/o8/ud?be=o8: 501
我尝试直接针对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
我完全不知所措,我真的可以使用一些帮助。