当前位置: 首页>>代码示例>>Python>>正文


Python FetchResponse.fromSuccessResponse方法代码示例

本文整理汇总了Python中openid.extensions.ax.FetchResponse.fromSuccessResponse方法的典型用法代码示例。如果您正苦于以下问题:Python FetchResponse.fromSuccessResponse方法的具体用法?Python FetchResponse.fromSuccessResponse怎么用?Python FetchResponse.fromSuccessResponse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openid.extensions.ax.FetchResponse的用法示例。


在下文中一共展示了FetchResponse.fromSuccessResponse方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: from_openid_response

# 需要导入模块: from openid.extensions.ax import FetchResponse [as 别名]
# 或者: from openid.extensions.ax.FetchResponse import fromSuccessResponse [as 别名]
def from_openid_response(openid_response):
    issued = int(time.time())
 
    openid = OpenID(openid_response.identity_url, issued, openid_response.signed_fields)
    if getattr(settings, 'OPENID_SREG', False):
        openid.sreg = SRegResponse.fromSuccessResponse(openid_response)
 
    if getattr(settings, 'OPENID_AX', False):
        openid.ax = AXFetchResponse.fromSuccessResponse(openid_response)
 
    return openid
开发者ID:Zojax,项目名称:zojax.django.socialauthentication,代码行数:13,代码来源:utils.py

示例2: get_email_from_response

# 需要导入模块: from openid.extensions.ax import FetchResponse [as 别名]
# 或者: from openid.extensions.ax.FetchResponse import fromSuccessResponse [as 别名]
def get_email_from_response(response):
    email = None
    sreg = SRegResponse.fromSuccessResponse(response)
    if sreg:
        email = valid_email_or_none(sreg.get(SRegField.EMAIL))
    if not email:
        ax = FetchResponse.fromSuccessResponse(response)
        if ax:
            try:
                values = ax.get(AXAttribute.CONTACT_EMAIL)
                if values:
                    email = valid_email_or_none(values[0])
            except KeyError:
                pass
    return email
开发者ID:pennersr,项目名称:django-allauth,代码行数:17,代码来源:utils.py

示例3: process_authentication_request

# 需要导入模块: from openid.extensions.ax import FetchResponse [as 别名]
# 或者: from openid.extensions.ax.FetchResponse import fromSuccessResponse [as 别名]
    def process_authentication_request(self, request):
        consumer = Consumer(request.session, OsqaOpenIDStore())

        query_dict = dict([
            (k.encode('utf8'), v.encode('utf8')) for k, v in request.GET.items()
        ])

        #for i in query_dict.items():
            #print "%s : %s" % i

        url = get_url_host(request) + request.path
        openid_response = consumer.complete(query_dict, url)

        if openid_response.status == SUCCESS:
            if request.session.get('force_email_request', True):
                try:
                    ax = AXFetchResponse.fromSuccessResponse(openid_response)

                    axargs = ax.getExtensionArgs()

                    ax_schema2data_type = dict([(s, t) for t, s in self.dataype2ax_schema.items()])

                    available_types = dict([
                        (ax_schema2data_type[s], re.sub('^type\.', '', n))
                        for n, s in axargs.items() if s in ax_schema2data_type
                    ])

                    available_data = dict([
                        (t, axargs["value.%s.1" % s]) for t, s in available_types.items()
                    ])
                    
                    request.session['auth_consumer_data'] = {
                        'email': available_data.get('email', None),
                    }

                except Exception, e:
                    pass
                    #import sys, traceback
                    #traceback.print_exc(file=sys.stdout)

            return request.GET['openid.identity']
开发者ID:boothead,项目名称:OSQA,代码行数:43,代码来源:consumer.py

示例4: get_value_from_response

# 需要导入模块: from openid.extensions.ax import FetchResponse [as 别名]
# 或者: from openid.extensions.ax.FetchResponse import fromSuccessResponse [as 别名]
def get_value_from_response(response, sreg_names=None, ax_names=None):
    value = None
    if sreg_names:
        sreg = SRegResponse.fromSuccessResponse(response)
        if sreg:
            for name in sreg_names:
                value = sreg.get(name)
                if value:
                    break

    if not value and ax_names:
        ax = FetchResponse.fromSuccessResponse(response)
        if ax:
            for name in ax_names:
                try:
                    values = ax.get(name)
                    if values:
                        value = values[0]
                except KeyError:
                    pass
                if value:
                    break
    return value
开发者ID:pennersr,项目名称:django-allauth,代码行数:25,代码来源:utils.py

示例5: process_authentication_request

# 需要导入模块: from openid.extensions.ax import FetchResponse [as 别名]
# 或者: from openid.extensions.ax.FetchResponse import fromSuccessResponse [as 别名]
    def process_authentication_request(self, request):
        consumer = Consumer(request.session, OsqaOpenIDStore())

        query_dict = dict([
            (k.encode('utf8'), v.encode('utf8')) for k, v in request.GET.items()
        ])

        #for i in query_dict.items():
        #    print "%s : %s" % i

        url = get_url_host(request) + request.path
        openid_response = consumer.complete(query_dict, url)

        if openid_response.status == SUCCESS:
            if request.session.get('force_email_request', True):
                try:
                    ax = AXFetchResponse.fromSuccessResponse(openid_response)
                    email = ax.getExtensionArgs()['value.ext0.1']
                    request.session['auth_email_request'] = email
                except Exception, e:
                    pass

            return request.GET['openid.identity']
开发者ID:Cka3o4Huk,项目名称:osqa-1,代码行数:25,代码来源:consumer.py

示例6: get_extra_data

# 需要导入模块: from openid.extensions.ax import FetchResponse [as 别名]
# 或者: from openid.extensions.ax.FetchResponse import fromSuccessResponse [as 别名]
 def get_extra_data(self, resp):
     return FetchResponse.fromSuccessResponse(resp)
开发者ID:ilblackdragon,项目名称:django-netauth,代码行数:4,代码来源:google.py

示例7: process_authentication_request

# 需要导入模块: from openid.extensions.ax import FetchResponse [as 别名]
# 或者: from openid.extensions.ax.FetchResponse import fromSuccessResponse [as 别名]
    def process_authentication_request(self, request):
        consumer = Consumer(request.session, OsqaOpenIDStore())

        query_dict = dict([
            (k.encode('utf8'), v.encode('utf8')) for k, v in request.GET.items()
        ])

        #for i in query_dict.items():
            #print "%s : %s" % i

        url = get_url_host(request) + request.path
        openid_response = consumer.complete(query_dict, url)

        if openid_response.status == SUCCESS:

            consumer_data = {}

            sreg_attrs = getattr(self, 'sreg_attributes', False)

            if sreg_attrs:
                sreg_response = SRegResponse.fromSuccessResponse(openid_response)

                if sreg_response:
                    all_attrs = {}
                    [all_attrs.update(d) for k,d in sreg_attrs.items() if k != "policy_url"]

                    for attr_name, local_name in all_attrs.items():
                        if attr_name in sreg_response:
                            consumer_data[local_name] = sreg_response[attr_name]

            ax_schema = getattr(self, 'dataype2ax_schema', False)

            if ax_schema:
                ax = AXFetchResponse.fromSuccessResponse(openid_response)

                if ax:
                    axargs = ax.getExtensionArgs()

                    ax_schema2data_type = dict([(s, t) for t, s in ax_schema.items()])

                    available_types = dict([
                        (ax_schema2data_type[s], re.sub('^type\.', '', n))
                        for n, s in axargs.items() if s in ax_schema2data_type
                    ])

                    for t, s in available_types.items():
                        if not t in consumer_data:
                            if axargs.get("value.%s.1" % s, None):
                                consumer_data[t] = axargs["value.%s.1" % s]
                    
            request.session['auth_consumer_data'] = consumer_data


            return request.GET['openid.identity']
        elif openid_response.status == CANCEL:
            raise InvalidAuthentication(_('The OpenId authentication request was canceled'))
        elif openid_response.status == FAILURE:
            raise InvalidAuthentication(_('The OpenId authentication failed: ') + openid_response.message)
        elif openid_response.status == SETUP_NEEDED:
            raise InvalidAuthentication(_('Setup needed'))
        else:
            raise InvalidAuthentication(_('The OpenId authentication failed with an unknown status: ') + openid_response.status)
开发者ID:Granicus,项目名称:civipedia,代码行数:64,代码来源:consumer.py


注:本文中的openid.extensions.ax.FetchResponse.fromSuccessResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。