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


Python ErrorResponse.get_json方法代码示例

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


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

示例1: handle_registration_info

# 需要导入模块: from oic.oauth2.message import ErrorResponse [as 别名]
# 或者: from oic.oauth2.message.ErrorResponse import get_json [as 别名]
    def handle_registration_info(self, response):
        if response.status_code == 200:
            resp = RegistrationResponse().deserialize(response.text, "json")
            self.store_registration_info(resp)
        else:
            err = ErrorResponse().deserialize(response.text, "json")
            raise PyoidcError("Registration failed: %s" % err.get_json())

        return resp
开发者ID:jeffthieleke-wf,项目名称:pyoidc,代码行数:11,代码来源:__init__.py

示例2: handle_registration_info

# 需要导入模块: from oic.oauth2.message import ErrorResponse [as 别名]
# 或者: from oic.oauth2.message.ErrorResponse import get_json [as 别名]
    def handle_registration_info(self, response):
        if response.status_code == 200:
            resp = RegistrationResponse().deserialize(response.text, "json")
            self.registration_response = resp
            self.client_secret = resp["client_secret"]
            self.client_id = resp["client_id"]
            self.registration_expires = resp["client_secret_expires_at"]
            self.registration_access_token = resp["registration_access_token"]
        else:
            err = ErrorResponse().deserialize(response.text, "json")
            raise PyoidcError("Registration failed: %s" % err.get_json())

        return resp
开发者ID:hdknr,项目名称:pyoidc,代码行数:15,代码来源:__init__.py

示例3: register

# 需要导入模块: from oic.oauth2.message import ErrorResponse [as 别名]
# 或者: from oic.oauth2.message.ErrorResponse import get_json [as 别名]
    def register(self, url, operation="register", application_type="web",
                 **kwargs):
        req = RegistrationRequest(operation=operation,
                                  application_type=application_type)

        if operation == "update":
            req["client_id"] = self.client_id
            req["client_secret"] = self.client_secret

        for prop in req.parameters():
            if prop in ["operation", "client_id", "client_secret"]:
                continue

            try:
                req[prop] = kwargs[prop]
            except KeyError:
                try:
                    req[prop] = self.behaviour[prop]
                except KeyError:
                    pass

        if "redirect_uris" not in req:
            try:
                req["redirect_uris"] = self.redirect_uris
            except AttributeError:
                raise MissingRequiredAttribute("redirect_uris")

        headers = {"content-type": "application/x-www-form-urlencoded"}

        if operation == "client_update":
            headers["Authorization"] = "Bearer %s" % self.registration_access_token

        rsp = self.http_request(url, "POST", data=req.to_urlencoded(),
                                headers=headers)

        if rsp.status_code == 200:
            resp = RegistrationResponse().deserialize(rsp.text, "json")
            self.client_secret = resp["client_secret"]
            self.client_id = resp["client_id"]
            self.registration_expires = resp["expires_at"]
            self.registration_access_token = resp["registration_access_token"]
        else:
            err = ErrorResponse().deserialize(rsp.text, "json")
            raise Exception("Registration failed: %s" % err.get_json())

        return resp
开发者ID:asheidan,项目名称:pyoidc,代码行数:48,代码来源:__init__.py

示例4: register

# 需要导入模块: from oic.oauth2.message import ErrorResponse [as 别名]
# 或者: from oic.oauth2.message.ErrorResponse import get_json [as 别名]
    def register(self, server, type="client_associate", **kwargs):
        req = RegistrationRequest(type=type)

        if type == "client_update" or type == "rotate_secret":
            req["client_id"] = self.client_id
            req["client_secret"] = self.client_secret

        for prop in req.parameters():
            if prop in ["type", "client_id", "client_secret"]:
                continue

            try:
                val = getattr(self, prop)
                if val:
                    req[prop] = val
            except Exception:
                val = None

            if not val:
                try:
                    req[prop] = kwargs[prop]
                except KeyError:
                    pass

        headers = {"content-type": "application/x-www-form-urlencoded"}
        rsp = self.http_request(server, "POST", data=req.to_urlencoded(),
                                headers=headers)

        if rsp.status_code == 200:
            if type == "client_associate" or type == "rotate_secret":
                rr = RegistrationResponseCARS()
            else:
                rr = RegistrationResponseCU()

            resp = rr.deserialize(rsp.text, "json")
            self.client_secret = resp["client_secret"]
            self.client_id = resp["client_id"]
            self.registration_expires = resp["expires_at"]
        else:
            err = ErrorResponse().deserialize(rsp.text, "json")
            raise Exception("Registration failed: %s" % err.get_json())

        return resp
开发者ID:imsoftware,项目名称:pyoidc,代码行数:45,代码来源:consumer.py


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