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


Python AuthorizationRequest.to_urlencoded方法代码示例

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


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

示例1: test_deserialize_urlencoded

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_urlencoded [as 别名]
    def test_deserialize_urlencoded(self):
        ar = AuthorizationRequest(response_type=["code"],
                                  client_id="foobar")
        urlencoded = ar.to_urlencoded()
        ar2 = AuthorizationRequest().deserialize(urlencoded, "urlencoded")

        assert ar == ar2
开发者ID:Omosofe,项目名称:pyoidc,代码行数:9,代码来源:test_oauth2_message.py

示例2: test_urlencoded_with_scope

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_urlencoded [as 别名]
    def test_urlencoded_with_scope(self):
        ar = AuthorizationRequest(response_type=["code"], client_id="foobar",
                                  redirect_uri="http://foobar.example.com/oaclient",
                                  scope=["foo", "bar"], state="cold")

        ue = ar.to_urlencoded()
        assert query_string_compare(ue,
                                    "scope=foo+bar&state=cold&redirect_uri=http%3A%2F%2Ffoobar.example.com%2Foaclient&response_type=code&client_id=foobar")
开发者ID:Omosofe,项目名称:pyoidc,代码行数:10,代码来源:test_oauth2_message.py

示例3: test_deserialize_urlencoded_multiple_params

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_urlencoded [as 别名]
    def test_deserialize_urlencoded_multiple_params(self):
        ar = AuthorizationRequest(response_type=["code"],
                                  client_id="foobar",
                                  redirect_uri="http://foobar.example.com/oaclient",
                                  scope=["foo", "bar"], state="cold")
        urlencoded = ar.to_urlencoded()
        ar2 = AuthorizationRequest().deserialize(urlencoded, "urlencoded")

        assert ar == ar2
开发者ID:Omosofe,项目名称:pyoidc,代码行数:11,代码来源:test_oauth2_message.py

示例4: test_urlencoded_resp_type_token

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_urlencoded [as 别名]
    def test_urlencoded_resp_type_token(self):
        ar = AuthorizationRequest(response_type=["token"],
                                  client_id="s6BhdRkqt3",
                                  redirect_uri="https://client.example.com/cb",
                                  state="xyz")

        ue = ar.to_urlencoded()
        assert query_string_compare(ue,
                                    "state=xyz&redirect_uri=https%3A%2F%2Fclient.example.com%2Fcb&response_type=token&client_id=s6BhdRkqt3")
开发者ID:Omosofe,项目名称:pyoidc,代码行数:11,代码来源:test_oauth2_message.py

示例5: test_authorization_endpoint_faulty_redirect_uri

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_urlencoded [as 别名]
    def test_authorization_endpoint_faulty_redirect_uri(self):
        bib = {"state": "id-6da9ca0cc23959f5f33e8becd9b08cae",
               # faulty redirect uri
               "redirect_uri": "http://localhost:8087/cb",
               "response_type": ["code"],
               "client_id": "a1b2c3"}

        arq = AuthorizationRequest(**bib)
        resp = self.provider.authorization_endpoint(request=arq.to_urlencoded())
        assert resp.status == "400 Bad Request"
        msg = json.loads(resp.message)
        assert msg["error"] == "invalid_request"
开发者ID:Omosofe,项目名称:pyoidc,代码行数:14,代码来源:test_ext_provider.py

示例6: test_multiple_response_types_urlencoded

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_urlencoded [as 别名]
    def test_multiple_response_types_urlencoded(self):
        ar = AuthorizationRequest(response_type=["code", "token"],
                                  client_id="foobar")

        ue = ar.to_urlencoded()
        ue_splits = ue.split('&')
        expected_ue_splits = "response_type=code+token&client_id=foobar".split(
            '&')
        assert _eq(ue_splits, expected_ue_splits)

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

示例7: test_authorization_endpoint_faulty_redirect_uri_nwalker

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_urlencoded [as 别名]
    def test_authorization_endpoint_faulty_redirect_uri_nwalker(self):
        bib = {"scope": ["openid"],
               "state": "id-6da9ca0cc23959f5f33e8becd9b08cae",
               "redirect_uri": " https://example.com.evil.com",
               # faulty redirect uri
               "response_type": ["code"],
               "client_id": "a1b2c3"}

        arq = AuthorizationRequest(**bib)
        resp = self.provider.authorization_endpoint(request=arq.to_urlencoded())
        assert resp.status_code == 400
        msg = json.loads(resp.message)
        assert msg["error"] == "invalid_request"
开发者ID:Magosgruss,项目名称:pyoidc,代码行数:15,代码来源:test_oauth2_provider.py

示例8: test_provider_authorization_endpoint

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_urlencoded [as 别名]
def test_provider_authorization_endpoint():
    provider = Provider("pyoicserv", sdb.SessionDB(), CDB, AUTHN_BROKER, AUTHZ,
                        verify_client)

    bib = {"scope": ["openid"],
           "state": "id-6da9ca0cc23959f5f33e8becd9b08cae",
           "redirect_uri": "http://localhost:8087authz",
           "response_type": ["code"],
           "client_id": "a1b2c3"}

    arq = AuthorizationRequest(**bib)

    QUERY_STRING = arq.to_urlencoded()

    resp = provider.authorization_endpoint(request=QUERY_STRING)

    assert isinstance(resp, Response)
开发者ID:dash-dash,项目名称:pyoidc,代码行数:19,代码来源:test_oauth2_provider.py

示例9: test_response_types

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

        self.provider.cdb = {
            "client1": {
                "client_secret": "hemlighet",
                "redirect_uris": [("http://example.com/authz", None)],
                'token_endpoint_auth_method': 'client_secret_post',
                'response_types': response_types
            }
        }

        res = self.provider.auth_init(authreq.to_urlencoded())
        assert isinstance(res, dict) and "areq" in res
开发者ID:Magosgruss,项目名称:pyoidc,代码行数:19,代码来源:test_oauth2_provider.py

示例10: test_provider_authorization_endpoint

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_urlencoded [as 别名]
def test_provider_authorization_endpoint():
    provider = Provider("pyoicserv", sdb.SessionDB(), CDB, FUNCTIONS)

    bib = {"scope": ["openid"],
           "state": "id-6da9ca0cc23959f5f33e8becd9b08cae",
           "redirect_uri": "http://localhost:8087authz",
           "response_type": ["code"],
           "client_id": "a1b2c3"}

    arq = AuthorizationRequest(**bib)

    environ = BASE_ENVIRON.copy()
    environ["QUERY_STRING"] = arq.to_urlencoded()

    resp = provider.authorization_endpoint(environ, start_response)

    print resp
    assert resp[0].startswith("FORM with")
开发者ID:asheidan,项目名称:pyoidc,代码行数:20,代码来源:test_oauth2_provider.py

示例11: test_response_types_fail

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

        self.provider.cdb = {
            "client1": {
                "client_secret": "hemlighet",
                "redirect_uris": [("http://example.com/authz", None)],
                'token_endpoint_auth_method': 'client_secret_post',
                'response_types': response_types
            }
        }

        res = self.provider.auth_init(authreq.to_urlencoded())
        assert isinstance(res, Response)

        _res = json.loads(res.message)
        assert _res['error'] == 'invalid_request'
开发者ID:Magosgruss,项目名称:pyoidc,代码行数:22,代码来源:test_oauth2_provider.py

示例12: test_parse_authz_req

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_urlencoded [as 别名]
    def test_parse_authz_req(self):
        ar = AuthorizationRequest(
            response_type=["code"], client_id="foobar", redirect_uri="http://foobar.example.com/oaclient", state="cold"
        )

        uencq = ar.to_urlencoded()

        areq = self.srv.parse_authorization_request(query=uencq)

        assert isinstance(areq, AuthorizationRequest)
        assert areq["response_type"] == ["code"]
        assert areq["client_id"] == "foobar"
        assert areq["redirect_uri"] == "http://foobar.example.com/oaclient"
        assert areq["state"] == "cold"

        urluenc = "%s?%s" % ("https://example.com/authz", uencq)
        areq = self.srv.parse_authorization_request(url=urluenc)

        assert isinstance(areq, AuthorizationRequest)
        assert areq["response_type"] == ["code"]
        assert areq["client_id"] == "foobar"
        assert areq["redirect_uri"] == "http://foobar.example.com/oaclient"
        assert areq["state"] == "cold"
开发者ID:joostd,项目名称:pyoidc,代码行数:25,代码来源:test_oauth2.py

示例13: test_authz_req_urlencoded

# 需要导入模块: from oic.oauth2.message import AuthorizationRequest [as 别名]
# 或者: from oic.oauth2.message.AuthorizationRequest import to_urlencoded [as 别名]
 def test_authz_req_urlencoded(self):
     ar = AuthorizationRequest(response_type=["code"], client_id="foobar")
     ue = ar.to_urlencoded()
     assert query_string_compare(ue, "response_type=code&client_id=foobar")
开发者ID:Omosofe,项目名称:pyoidc,代码行数:6,代码来源:test_oauth2_message.py


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