2011-05-12 69 views
3

我已经能够最终获得python-openid来验证用户,但我无法创建sreg.SRegResponse或ax.FetchResponse,因为他们回来了作为无。这是来自Google Apps帐户,我试图按照https://github.com/openid/python-openid/tree/master/examples/djopenid的示例进行操作。我听说过谷歌的OpenID系统可以是一个有点古怪,需要一些调整,像Retrieve OpenID AX attributes from Google/Yahoo in Railspython-openid不提供ax或sreg属性

response = c.complete(request_args, return_to) 

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

的反应肯定是回来是成功的,但我看到下面的错误消息,这可能与:

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 

这是我的设置。

  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) 

回答

4

我在使用AttributeExchange时遇到了Google返回值不是schema.openid.net的问题。它就像你刚才提到的那样返回None,最糟糕的部分是,当我第一次写我的OpenID处理程序时,它曾经工作过。

一旦我切换到我的执行中的axschema值,它就像一个魅力。例如:

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) 
+0

对不起,延迟响应,但我忘了这个线程,并转移到我的项目中的其他事情。当我回到OpenID部分时,我不得不回到在尝试修复之前发布的原始问题,这很好。 – voodoogiant 2011-07-02 19:21:36

+0

宾果!现在与我的金字塔应用程序合作。谢谢 :-) – 2013-03-11 07:18:38

相关问题