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


Python OpenIDSchema.keys方法代碼示例

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


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

示例1: test_userinfo_endpoint

# 需要導入模塊: from oic.oic.message import OpenIDSchema [as 別名]
# 或者: from oic.oic.message.OpenIDSchema import keys [as 別名]
def test_userinfo_endpoint():
    server = provider_init

    _session_db = {}
    cons = Consumer(_session_db, CONSUMER_CONFIG, CLIENT_CONFIG,
                    server_info=SERVER_INFO)
    cons.debug = True
    cons.client_secret = "drickyoughurt"
    cons.config["response_type"] = ["token"]
    cons.config["request_method"] = "parameter"
    cons.keyjar[""] = KC_RSA

    location = cons.begin("openid", "token", path="http://localhost:8087")

    resp = server.authorization_endpoint(request=location.split("?")[1])

    line = resp.message
    path, query = line.split("?")

    # redirect
    atr = AuthorizationResponse().deserialize(query, "urlencoded")

    uir = UserInfoRequest(access_token=atr["access_token"], schema="openid")

    resp3 = server.userinfo_endpoint(request=uir.to_urlencoded())
    ident = OpenIDSchema().deserialize(resp3.message, "json")
    print ident.keys()
    assert _eq(ident.keys(), ['nickname', 'sub', 'name', 'email'])
    assert ident["sub"] == USERDB["username"]["sub"]
開發者ID:biancini,項目名稱:pyoidc,代碼行數:31,代碼來源:test_oic_provider.py

示例2: test_userinfo_endpoint

# 需要導入模塊: from oic.oic.message import OpenIDSchema [as 別名]
# 或者: from oic.oic.message.OpenIDSchema import keys [as 別名]
def test_userinfo_endpoint():
    server = provider_init

    _session_db = {}
    cons = Consumer(_session_db, CONSUMER_CONFIG, CLIENT_CONFIG,
                    server_info=SERVER_INFO)
    cons.debug = True
    cons.client_secret = "drickyoughurt"
    cons.config["response_type"] = ["token"]
    cons.config["request_method"] = "parameter"
    cons.keyjar[""] = KC_RSA

    environ = BASE_ENVIRON

    location = cons.begin(environ, start_response)

    environ = BASE_ENVIRON.copy()
    environ["QUERY_STRING"] = location.split("?")[1]

    resp = server.authorization_endpoint(environ, start_response)

    sid = resp[0][len("<form>"):-len("</form>")]
    environ2 = create_return_form_env("user", "password", sid)

    resp2 = server.authenticated(environ2, start_response)
    line = resp2[0]
    start = line.index("<title>")
    start += len("<title>Redirecting to ")
    stop = line.index("</title>")
    path, query = line[start:stop].split("?")

    # redirect
    atr = AuthorizationResponse().deserialize(query, "urlencoded")

    uir = UserInfoRequest(access_token=atr["access_token"], schema="openid")

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

    resp3 = server.userinfo_endpoint(environ, start_response)
    ident = OpenIDSchema().deserialize(resp3[0], "json")
    print ident.keys()
    assert _eq(ident.keys(), ['nickname', 'sub', 'name', 'email'])
    assert ident["sub"] == USERDB["user"]["sub"]
開發者ID:asheidan,項目名稱:pyoidc,代碼行數:46,代碼來源:test_oic_provider.py

示例3: test_userinfo_endpoint

# 需要導入模塊: from oic.oic.message import OpenIDSchema [as 別名]
# 或者: from oic.oic.message.OpenIDSchema import keys [as 別名]
    def test_userinfo_endpoint(self):
        self.cons.client_secret = "drickyoughurt"
        self.cons.config["response_type"] = ["token"]
        self.cons.config["request_method"] = "parameter"

        state, location = self.cons.begin("openid", "token",
                                          path="http://localhost:8087")

        resp = self.server.authorization_endpoint(request=location.split("?")[1])

        line = resp.message
        path, query = line.split("#")

        # redirect
        atr = AuthorizationResponse().deserialize(query, "urlencoded")

        uir = UserInfoRequest(access_token=atr["access_token"], schema="openid")

        resp3 = self.server.userinfo_endpoint(request=uir.to_urlencoded())
        ident = OpenIDSchema().deserialize(resp3.message, "json")
        print ident.keys()
        assert _eq(ident.keys(), ['nickname', 'sub', 'name', 'email'])
開發者ID:dallerbarn,項目名稱:pyoidc,代碼行數:24,代碼來源:test_oic_provider.py

示例4: test_userinfo_endpoint_authn

# 需要導入模塊: from oic.oic.message import OpenIDSchema [as 別名]
# 或者: from oic.oic.message.OpenIDSchema import keys [as 別名]
    def test_userinfo_endpoint_authn(self):
        self.cons.client_secret = "drickyoughurt"
        self.cons.config["response_type"] = ["token"]
        self.cons.config["request_method"] = "parameter"
        state, location = self.cons.begin("openid", "token", path="http://localhost:8087")

        resp = self.provider.authorization_endpoint(request=urlparse(location).query)

        # redirect
        atr = AuthorizationResponse().deserialize(urlparse(resp.message).fragment, "urlencoded")

        uir = UserInfoRequest(schema="openid")

        resp = self.provider.userinfo_endpoint(request=uir.to_urlencoded(), authn="Bearer " + atr["access_token"])
        ident = OpenIDSchema().deserialize(resp.message, "json")
        assert _eq(ident.keys(), ["nickname", "sub", "name", "email"])
開發者ID:htobenothing,項目名稱:pyoidc,代碼行數:18,代碼來源:test_oic_provider.py


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