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


Python AuthorizationRequest.to_json方法代码示例

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


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

示例1: test_token_endpoint_unauth

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_json [as 别名]
    def test_token_endpoint_unauth(self):
        authreq = AuthorizationRequest(state="state",
                                       redirect_uri="http://example.com/authz",
                                       client_id="client1",
                                       response_type='code')

        _sdb = self.provider.sdb
        sid = _sdb.access_token.key(user="sub", areq=authreq)
        access_grant = _sdb.token_factory['code'](sid=sid)
        _sdb[sid] = {
            "oauth_state": "authz",
            "sub": "sub",
            "authzreq": authreq.to_json(),
            "client_id": "client1",
            "code": access_grant,
            "code_used": False,
            "redirect_uri": "http://example.com/authz",
            'response_type': ['code']
        }

        # Construct Access token request
        areq = AccessTokenRequest(code=access_grant,
                                  redirect_uri="http://example.com/authz",
                                  client_id="client2",
                                  client_secret="hemlighet",
                                  grant_type='authorization_code')

        resp = self.provider.token_endpoint(request=areq.to_urlencoded())
        atr = TokenErrorResponse().deserialize(resp.message, "json")
        assert _eq(atr.keys(), ['error_description', 'error'])
开发者ID:Omosofe,项目名称:pyoidc,代码行数:32,代码来源:test_ext_provider.py

示例2: test_token_introspection

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_json [as 别名]
    def test_token_introspection(self):
        authreq = AuthorizationRequest(state="state", redirect_uri="http://example.com/authz", client_id="client1")

        _sdb = self.provider.sdb
        sid = _sdb.access_token.key(user="sub", areq=authreq)
        access_grant = _sdb.token_factory["code"](sid=sid)
        _sdb[sid] = {
            "oauth_state": "authz",
            "sub": "sub",
            "authzreq": authreq.to_json(),
            "client_id": "client1",
            "code": access_grant,
            "code_used": False,
            "redirect_uri": "http://example.com/authz",
            "response_type": ["code"],
        }

        # Construct Access token request
        areq = AccessTokenRequest(
            code=access_grant,
            redirect_uri="http://example.com/authz",
            client_id="client1",
            client_secret="hemlighet",
            grant_type="authorization_code",
        )

        resp = self.provider.token_endpoint(request=areq.to_urlencoded())
        atr = AccessTokenResponse().deserialize(resp.message, "json")
        req = TokenIntrospectionRequest(
            token=atr["access_token"], client_id="client1", client_secret="hemlighet", token_type_hint="access_token"
        )
        resp = self.provider.introspection_endpoint(request=req.to_urlencoded())
        assert resp
        ti_resp = TokenIntrospectionResponse().deserialize(resp.message, "json")
        assert ti_resp["active"] is True
开发者ID:simudream,项目名称:pyoidc,代码行数:37,代码来源:test_ext_provider.py

示例3: test_multiple_response_types_json

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_json [as 别名]
    def test_multiple_response_types_json(self):
        ar = AuthorizationRequest(response_type=["code", "token"],
                                  client_id="foobar")
        ue = ar.to_json()
        ue_obj = json.loads(ue)
        expected_ue_obj = {
            "response_type": "code token",
            "client_id": "foobar"
        }
        assert ue_obj == expected_ue_obj

        are = AuthorizationRequest().deserialize(ue, "json")
        assert _eq(are.keys(), ["response_type", "client_id"])
        assert _eq(are["response_type"], ["code", "token"])
开发者ID:Omosofe,项目名称:pyoidc,代码行数:16,代码来源:test_oauth2_message.py


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