當前位置: 首頁>>代碼示例>>Python>>正文


Python AuthorizationResponse.to_urlencoded方法代碼示例

本文整理匯總了Python中oic.oauth2.message.AuthorizationResponse.to_urlencoded方法的典型用法代碼示例。如果您正苦於以下問題:Python AuthorizationResponse.to_urlencoded方法的具體用法?Python AuthorizationResponse.to_urlencoded怎麽用?Python AuthorizationResponse.to_urlencoded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在oic.oauth2.message.AuthorizationResponse的用法示例。


在下文中一共展示了AuthorizationResponse.to_urlencoded方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_consumer_client_get_access_token_reques

# 需要導入模塊: from oic.oauth2.message import AuthorizationResponse [as 別名]
# 或者: from oic.oauth2.message.AuthorizationResponse import to_urlencoded [as 別名]
def test_consumer_client_get_access_token_reques():
    _session_db = {}
    cons = Consumer(_session_db, client_config=CLIENT_CONFIG,
                    server_info=SERVER_INFO, **CONSUMER_CONFIG)
    cons.client_secret = "secret0"
    _state = "state"
    cons.redirect_uris = ["https://www.example.com/oic/cb"]

    resp1 = AuthorizationResponse(code="auth_grant", state=_state)
    cons.parse_response(AuthorizationResponse, resp1.to_urlencoded(),
                        "urlencoded")
    resp2 = AccessTokenResponse(access_token="token1",
                                token_type="Bearer", expires_in=0,
                                state=_state)
    cons.parse_response(AccessTokenResponse, resp2.to_urlencoded(),
                        "urlencoded")

    url, body, http_args = cons.get_access_token_request(_state)
    assert url == "http://localhost:8088/token"
    print body
    assert body == ("code=auth_grant&client_secret=secret0&"
                    "grant_type=authorization_code&client_id=number5&"
                    "redirect_uri=https%3A%2F%2Fwww.example.com%2Foic%2Fcb")
    assert http_args == {'headers': {
        'Content-type': 'application/x-www-form-urlencoded'}}
開發者ID:takehikokodama,項目名稱:pyoidc,代碼行數:27,代碼來源:test_oauth2_consumer.py

示例2: test_handle_authorization_response

# 需要導入模塊: from oic.oauth2.message import AuthorizationResponse [as 別名]
# 或者: from oic.oauth2.message.AuthorizationResponse import to_urlencoded [as 別名]
    def test_handle_authorization_response(self):
        sid, loc = self.consumer.begin("http://localhost:8087",
                                       "http://localhost:8088/authorization")

        atr = AuthorizationResponse(code="SplxlOBeZQQYbYS6WxSbIA",
                                    state=sid)

        res = self.consumer.handle_authorization_response(
            query=atr.to_urlencoded())

        assert isinstance(res, AuthorizationResponse)
        assert self.consumer.grant[sid].code == "SplxlOBeZQQYbYS6WxSbIA"
開發者ID:htobenothing,項目名稱:pyoidc,代碼行數:14,代碼來源:test_oauth2_consumer.py

示例3: test_consumer_handle_authorization_response

# 需要導入模塊: from oic.oauth2.message import AuthorizationResponse [as 別名]
# 或者: from oic.oauth2.message.AuthorizationResponse import to_urlencoded [as 別名]
def test_consumer_handle_authorization_response():
    _session_db = {}
    cons = Consumer(_session_db, client_config=CLIENT_CONFIG,
                    server_info=SERVER_INFO, **CONSUMER_CONFIG)
    cons.debug = True

    sid, loc = cons.begin("http://localhost:8087",
                          "http://localhost:8088/authorization")

    atr = AuthorizationResponse(code="SplxlOBeZQQYbYS6WxSbIA",
                                state=sid)

    res = cons.handle_authorization_response(query=atr.to_urlencoded())

    assert res.type() == "AuthorizationResponse"
    print cons.grant[sid]
    grant = cons.grant[sid]
    assert grant.code == "SplxlOBeZQQYbYS6WxSbIA"
開發者ID:takehikokodama,項目名稱:pyoidc,代碼行數:20,代碼來源:test_oauth2_consumer.py

示例4: test_consumer_handle_authorization_response

# 需要導入模塊: from oic.oauth2.message import AuthorizationResponse [as 別名]
# 或者: from oic.oauth2.message.AuthorizationResponse import to_urlencoded [as 別名]
def test_consumer_handle_authorization_response():
    _session_db = {}
    cons = Consumer(_session_db, client_config = CLIENT_CONFIG,
                    server_info=SERVER_INFO, **CONSUMER_CONFIG)
    cons.debug = True
    environ = BASE_ENVIRON

    _ = cons.begin(environ, start_response)

    atr = AuthorizationResponse(code="SplxlOBeZQQYbYS6WxSbIA",
                                state=cons.state)

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

    res = cons.handle_authorization_response(environ, start_response)

    assert res.type() == "AuthorizationResponse"
    print cons.grant[cons.state]
    grant = cons.grant[cons.state]
    assert grant.code == "SplxlOBeZQQYbYS6WxSbIA"
開發者ID:asheidan,項目名稱:pyoidc,代碼行數:23,代碼來源:test_oauth2_consumer.py


注:本文中的oic.oauth2.message.AuthorizationResponse.to_urlencoded方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。