首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python-openid不提供ax或sreg属性

python-openid不提供ax或sreg属性
EN

Stack Overflow用户
提问于 2011-05-12 22:07:40
回答 1查看 1.4K关注 0票数 3

我终于能够让python-openid对用户进行身份验证,但我无法创建sreg.SRegResponse或ax.FetchResponse,因为它们返回为None。这是来自谷歌应用程序的一个账号,我正在尝试效仿https://github.com/openid/python-openid/tree/master/examples/djopenid的例子。我听说谷歌的OpenID系统有点时髦,需要像Retrieve OpenID AX attributes from Google / Yahoo in Rails这样的一些调整

代码语言:javascript
复制
    response = c.complete(request_args, return_to)

    sreg_response = sreg.SRegResponse.fromSuccessResponse(response)
    ax_response = ax.FetchResponse.fromSuccessResponse(response)

响应肯定是成功的,但我看到了以下错误消息,这可能与此相关:

代码语言:javascript
复制
Generated checkid_setup request to https://www.google.com/accounts/o8/ud with assocication AOQobUdVBCrd-GZRcasn9tD-yOUF0Y8pJLAQrYXODqLxUUjN62G1BXR1
Error attempting to use stored discovery information: <openid.consumer.consumer.TypeURIMismatch: Required type http://specs.openid.net/auth/2.0/signon not found in ['http://specs.openid.net/auth/2.0/server', 'http://openid.net/srv/ax/1.0', 'http://specs.openid.net/extensions/ui/1.0/mode/popup', 'http://specs.openid.net/extensions/ui/1.0/icon', 'http://specs.openid.net/extensions/pape/1.0'] for endpoint <openid.consumer.discover.OpenIDServiceEndpoint server_url='https://www.google.com/accounts/o8/ud' claimed_id=None local_id=None canonicalID=None used_yadis=True >>
Attempting discovery to verify endpoint
Performing discovery on https://www.google.com/accounts/o8/id?id=AItOawkKU4uzJV9Q_FGMECNGsbiXG2caISYMyCw
Received id_res response from https://www.google.com/accounts/o8/ud using association AOQobUdVBCrd-GZRcasn9tD-yOUF0Y8pJLAQrYXODqLxUUjN62G1BXR1

这是我的设置。

代码语言:javascript
复制
           sreg_request = sreg.SRegRequest(optional=['email', 'nickname'],
                                        required=['dob'])
            auth_request.addExtension(sreg_request)

            # Add Attribute Exchange request information.
            ax_request = ax.FetchRequest()
            # XXX - uses myOpenID-compatible schema values, which are
            # not those listed at axschema.org.
            ax_request.add(ax.AttrInfo('http://schema.openid.net/namePerson',
                                       required=True))
            ax_request.add(ax.AttrInfo('http://schema.openid.net/contact/web/default',
                                       required=False, count=ax.UNLIMITED_VALUES))
            auth_request.addExtension(ax_request)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-08 00:25:58

我在谷歌返回AttributeExchange的schema.openid.net值时遇到了问题。就像你提到的那样,它没有返回任何内容,最糟糕的是,当我第一次编写OpenID处理程序时,它还能正常工作。

一旦我在我的实现中切换到axschema值,它就像一个护身符一样工作。例如:

代码语言:javascript
复制
    URLS = {
      'ax_email': 'http://axschema.org/contact/email',
      'ax_first': 'http://axschema.org/namePerson/first',
    }

    ...

    ax_request = ax.FetchRequest()
    ax_request.add(ax.AttrInfo(URLS['ax_email'], required = True))
    ax_request.add(ax.AttrInfo(URLS['ax_first'], required = True))

    auth_request.addExtension(ax_request)
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5979260

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档