How to use the oic.oauth2.message.AuthorizationRequest function in oic

To help you get started, we’ve selected a few oic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenIDC / pyoidc / tests / test_oauth2_message.py View on Github external
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"])
github OpenIDC / pyoidc / tests / test_oauth2_message.py View on Github external
def test_load_dict(self):
        bib = {
            "scope": ["openid"],
            "state": "id-6da9ca0cc23959f5f33e8becd9b08cae",
            "redirect_uri": "http://localhost:8087authz",
            "response_type": ["code"],
            "client_id": "a1b2c3",
        }

        arq = AuthorizationRequest(**bib)

        assert arq["scope"] == bib["scope"]
        assert arq["response_type"] == bib["response_type"]
        assert arq["redirect_uri"] == bib["redirect_uri"]
        assert arq["state"] == bib["state"]
        assert arq["client_id"] == bib["client_id"]
github OpenIDC / pyoidc / tests / test_oauth2_message.py View on Github external
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
github OpenIDC / pyoidc / tests / test_oauth2_message.py View on Github external
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
github OpenIDC / pyoidc / tests / test_oauth2_message.py View on Github external
def test_req_json_serialize(self):
        ar = AuthorizationRequest(response_type=["code"], client_id="foobar")

        js_obj = json.loads(ar.serialize(method="json"))
        expected_js_obj = {"response_type": "code", "client_id": "foobar"}
        assert js_obj == expected_js_obj
github OpenIDC / pyoidc / tests / test_oauth2.py View on Github external
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"
github OpenIDC / pyoidc / tests / oic / oauth2 / test_oauth2_message.py View on Github external
def test_json_multiple_params(self):
        ar = AuthorizationRequest(response_type=["code"],
                                  client_id="foobar",
                                  redirect_uri="http://foobar.example.com/oaclient",
                                  state="cold")

        ue_obj = json.loads(ar.serialize(method="json"))
        expected_ue_obj = {
            "response_type": "code",
            "state": "cold",
            "redirect_uri": "http://foobar.example.com/oaclient",
            "client_id": "foobar"
        }
        assert ue_obj == expected_ue_obj
github OpenIDC / pyoidc / tests / oic / oauth2 / test_oauth2_message.py View on Github external
def test_json_serialize_deserialize(self):
        ar = AuthorizationRequest(response_type=["code"],
                                  client_id="foobar")
        jtxt = ar.serialize(method="json")
        ar2 = AuthorizationRequest().deserialize(jtxt, "json")

        assert ar == ar2
github OpenIDC / pyoidc / tests / oic / oauth2 / test_oauth2_message.py View on Github external
def test_multiple_scopes_json(self):
        ar = AuthorizationRequest(response_type=["code", "token"],
                                  client_id="foobar",
                                  scope=["openid", "foxtrot"])
        ue = ar.to_json()
        ue_obj = json.loads(ue)
        expected_ue_obj = {
            "scope": "openid foxtrot",
            "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", "scope"])
        assert _eq(are["response_type"], ["code", "token"])
        assert _eq(are["scope"], ["openid", "foxtrot"])
github OpenIDC / pyoidc / tests / oic / oauth2 / test_oauth2_message.py View on Github external
def test_json_serialize_deserialize(self):
        ar = AuthorizationRequest(response_type=["code"],
                                  client_id="foobar")
        jtxt = ar.serialize(method="json")
        ar2 = AuthorizationRequest().deserialize(jtxt, "json")

        assert ar == ar2