Python OpenID错误:发现[uri]后找不到匹配的端点

时间:2010-03-02 16:38:02

标签: openid mod-python

当我调用消费者的complete()方法时,我发现“在发现[openid identifier]”后找不到匹配的端点错误。

有趣的是,在我测试过的四个OpenID提供程序中,只有LiveJournal才会出现此行为。您可以建议哪些步骤来调查并解决问题?

store = FileOpenIDStore("/path/to/store")

def login(req, uri):
    req.content_type = "text/html"
    session = Session.Session(req)
    consumer = Consumer(session, store)
    auth = consumer.begin(uri)
    util.redirect(req, auth.redirectURL("http://example.com", "http://example.com/authtest.py?sid=" + session.id()))
    return

def index(req, sid):
    req.content_type = "text/html"
    c = Consumer(Session.Session(req, sid), store)
    args = req.args.split("&")
    arg_dict = {}
    for i in range(0, len(args)):
        x, y = args[i].split("=")
        arg_dict[x] = unquote(y)
    v = c.complete(arg_dict, "http://example.com/authtest.py?" + req.args)
    if v.status == 'failure':
        return v.message
    else:
        return v.status

1 个答案:

答案 0 :(得分:1)

我的代码中没有发现任何明显的错误,但以下是一些需要调查的步骤:

  • oidutil.log是否有任何输出?默认情况下它会记录到stderr,但如果您的Web服务器不允许您看到stderr,则可以覆盖它以登录到其他位置。

  • 捕获所有请求/响应。您可以使用类似TamperData的内容来获取通过浏览器传递的间接请求/响应,并将其从python-openid发行版提供给contrib/openid-parse,以使其更具可读性。

  • python-openid源代码分发中的示例使用者是否使用您的LJ标识符?如果是这样,示例和代码之间的请求/响应有何不同?

  • 您的LJ标识符中是否有标点符号?

  • LJ是您正在测试的唯一OpenID版本1.x提供商吗? (可能。希望剩下的不多。)

  • 您的参数解析可以使用urlparse.parse_qs,但我不确定这确实是个问题。 (并且parse_qs返回{key:[list-of-values]},而Consumer.complete期望{key:single-value},所以你必须将一个映射到另一个。)

相关问题