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


Python tools.fetch方法代码示例

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


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

示例1: get_user

# 需要导入模块: from gluon import tools [as 别名]
# 或者: from gluon.tools import fetch [as 别名]
def get_user(self):
        request = self.request
        if request.vars.token:
            user = Storage()
            data = urllib.urlencode(
                dict(apiKey=self.api_key, token=request.vars.token))
            auth_info_json = fetch(self.auth_url + '?' + data)
            auth_info = json.loads(auth_info_json)

            if auth_info['stat'] == 'ok':
                self.profile = auth_info['profile']
                provider = re.sub('[^\w\-]', '', self.profile['providerName'])
                user = self.mappings.get(
                    provider, self.mappings.default)(self.profile)
                return user
            elif self.on_login_failure:
                redirect(self.on_login_failure)
        return None 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:20,代码来源:rpx_account.py

示例2: get_user

# 需要导入模块: from gluon import tools [as 别名]
# 或者: from gluon.tools import fetch [as 别名]
def get_user(self):
        request = self.request
        user = None
        if request.vars.token:
            try:
                auth_url = self.auth_base_url + self.api_secret + "/" + request.vars.token
                json_data = fetch(auth_url, headers={'User-Agent': "LoginRadius - Python - SDK"})
                self.profile = json.loads(json_data)
                provider = self.profile['Provider']
                mapping = self.mappings.get(provider, self.mappings['default'])
                user = mapping(self.profile)
            except (ValueError, KeyError):
                pass
            if user is None and self.on_login_failure:
                redirect(self.on_login_failure)
        return user 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:18,代码来源:loginradius_account.py

示例3: get_user

# 需要导入模块: from gluon import tools [as 别名]
# 或者: from gluon.tools import fetch [as 别名]
def get_user(self):
        request = self.request
        if request.vars.assertion:
            audience = self.audience
            issuer = self.issuer
            assertion = XML(request.vars.assertion, sanitize=True)
            verify_data = {'assertion': assertion, 'audience': audience}
            auth_info_json = fetch(self.verify_url, data=verify_data)
            j = json.loads(auth_info_json)
            epoch_time = int(time.time() * 1000)  # we need 13 digit epoch time
            if j["status"] == "okay" and j["audience"] == audience and j['issuer'].endswith(issuer) and j['expires'] >= epoch_time:
                return dict(email=j['email'])
            elif self.on_login_failure:
                #print "status:  ", j["status"]=="okay", j["status"]
                #print "audience:", j["audience"]==audience, j["audience"], audience
                #print "issuer:  ", j["issuer"]==issuer, j["issuer"], issuer
                #print "expires:  ", j["expires"] >= epoch_time, j["expires"], epoch_time
                redirect(self.on_login_failure)
            else:
                redirect('https://login.persona.org')
        return None 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:23,代码来源:browserid_account.py

示例4: get_user

# 需要导入模块: from gluon import tools [as 别名]
# 或者: from gluon.tools import fetch [as 别名]
def get_user(self):
        request = self.request
        user = None
        if request.vars.connection_token:
            auth_url = "https://%s.api.oneall.com/connections/%s.json"  % \
                       (self.domain, request.vars.connection_token)
            auth_pw = "%s:%s" % (self.public_key,self.private_key)
            auth_pw = base64.b64encode(auth_pw)
            headers = dict(Authorization="Basic %s" % auth_pw)
            try:
                auth_info_json = fetch(auth_url,headers=headers)
                auth_info = json.loads(auth_info_json)
                data = auth_info['response']['result']['data']
                if data['plugin']['key'] == 'social_login':
                    if data['plugin']['data']['status'] == 'success':
                        userdata = data['user']
                        self.profile = userdata['identity']
                        source = self.profile['source']['key']
                        mapping = self.mappings.get(source,self.mappings['default'])
                        user = mapping(self.profile)
            except (ValueError, KeyError):
                pass
            if user is None and self.on_login_failure:
                    redirect(self.on_login_failure)
        return user 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:27,代码来源:oneall_account.py

示例5: get_user

# 需要导入模块: from gluon import tools [as 别名]
# 或者: from gluon.tools import fetch [as 别名]
def get_user(self):
        request = self.request
        user = None
        if request.vars.token:
            try:
                auth_url = self.auth_base_url + self.api_secret + "/" + request.vars.token
                json_data = fetch(auth_url, headers={'User-Agent': "LoginRadius - Python - SDK"})
                self.profile = json.loads(json_data)
                provider = self.profile['Provider']
                mapping = self.mappings.get(provider, self.mappings['default'])
                user = mapping(self.profile)
            except (JSONDecodeError, KeyError):
                pass
            if user is None and self.on_login_failure:
                redirect(self.on_login_failure)
        return user 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:18,代码来源:loginradius_account.py

示例6: get_user

# 需要导入模块: from gluon import tools [as 别名]
# 或者: from gluon.tools import fetch [as 别名]
def get_user(self):
        request = self.request
        user = None
        if request.vars.connection_token:
            auth_url = "https://%s.api.oneall.com/connections/%s.json"  % \
                       (self.domain, request.vars.connection_token)
            auth_pw = "%s:%s" % (self.public_key,self.private_key)
            auth_pw = base64.b64encode(auth_pw)
            headers = dict(Authorization="Basic %s" % auth_pw)
            try:
                auth_info_json = fetch(auth_url,headers=headers)
                auth_info = json.loads(auth_info_json)
                data = auth_info['response']['result']['data']
                if data['plugin']['key'] == 'social_login':
                    if data['plugin']['data']['status'] == 'success':
                        userdata = data['user']
                        self.profile = userdata['identity']
                        source = self.profile['source']['key']
                        mapping = self.mappings.get(source,self.mappings['default'])
                        user = mapping(self.profile)
            except (JSONDecodeError, KeyError):
                pass
            if user is None and self.on_login_failure:
                    redirect(self.on_login_failure)
        return user 
开发者ID:lucadealfaro,项目名称:true_review_web2py,代码行数:27,代码来源:oneall_account.py

示例7: get_user

# 需要导入模块: from gluon import tools [as 别名]
# 或者: from gluon.tools import fetch [as 别名]
def get_user(self):
        request = self.request
        if request.vars.assertion:
            audience = self.audience
            issuer = self.issuer
            assertion = XML(request.vars.assertion, sanitize=True)
            verify_data = {'assertion': assertion, 'audience': audience}
            auth_info_json = fetch(self.verify_url, data=verify_data)
            j = json.loads(auth_info_json)
            epoch_time = int(time.time() * 1000)  # we need 13 digit epoch time
            if j["status"] == "okay" and j["audience"] == audience and j['issuer'] == issuer and j['expires'] >= epoch_time:
                return dict(email=j['email'])
            elif self.on_login_failure:
                #print "status:  ", j["status"]=="okay", j["status"]
                #print "audience:", j["audience"]==audience, j["audience"], audience
                #print "issuer:  ", j["issuer"]==issuer, j["issuer"], issuer
                #print "expires:  ", j["expires"] >= epoch_time, j["expires"], epoch_time
                redirect(self.on_login_failure)
            else:
                redirect('https://login.persona.org')
        return None 
开发者ID:whbrewer,项目名称:spc,代码行数:23,代码来源:browserid_account.py


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