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


Python Grant.add_code方法代码示例

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


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

示例1: test_get_grant

# 需要导入模块: from oic.oauth2 import Grant [as 别名]
# 或者: from oic.oauth2.Grant import add_code [as 别名]
    def test_get_grant(self):
        resp = AuthorizationResponse(code="code", state="state")
        grant = Grant()
        grant.add_code(resp)

        self.client.grant["state"] = grant
        assert self.client.grant_from_state("state").code == "code"
开发者ID:joostd,项目名称:pyoidc,代码行数:9,代码来源:test_oauth2.py

示例2: test_grant_add_code

# 需要导入模块: from oic.oauth2 import Grant [as 别名]
# 或者: from oic.oauth2.Grant import add_code [as 别名]
def test_grant_add_code():
    ar = AuthorizationResponse(code="code", state="state")

    grant = Grant()
    grant.add_code(ar)
    assert grant
    assert grant.code == "code"
开发者ID:dajiaji,项目名称:pyoidc,代码行数:9,代码来源:test_oauth2.py

示例3: test_bearer_body

# 需要导入模块: from oic.oauth2 import Grant [as 别名]
# 或者: from oic.oauth2.Grant import add_code [as 别名]
def test_bearer_body():
    client = Client("A")
    client.client_secret = "boarding pass"

    request_args = {"access_token": "Sesame"}

    cis = ResourceRequest()
    http_args = BearerBody(client).construct(cis, request_args)
    assert cis["access_token"] == "Sesame"
    print http_args
    assert http_args is None

    # ----------
    resp = AuthorizationResponse(code="code", state="state")
    grant = Grant()
    grant.add_code(resp)

    atr = AccessTokenResponse(access_token="2YotnFZFEjr1zCsicMWpAA",
                              token_type="example",
                              refresh_token="tGzv3JOkF0XG5Qx2TlKWIA",
                              example_parameter="example_value",
                              scope=["inner", "outer"])

    grant.add_token(atr)
    client.grant["state"] = grant

    cis = ResourceRequest()
    http_args = BearerBody(client).construct(cis, {}, state="state",
                                             scope="inner")
    assert cis["access_token"] == "2YotnFZFEjr1zCsicMWpAA"
    print http_args
    assert http_args is None
开发者ID:dajiaji,项目名称:pyoidc,代码行数:34,代码来源:test_oauth2.py

示例4: test_grant_access_token_1

# 需要导入模块: from oic.oauth2 import Grant [as 别名]
# 或者: from oic.oauth2.Grant import add_code [as 别名]
def test_grant_access_token_1():
    resp = AuthorizationResponse(code="code", state="state")
    grant = Grant()
    grant.add_code(resp)

    atr = AccessTokenResponse(access_token="2YotnFZFEjr1zCsicMWpAA",
                              token_type="example", expires_in=1,
                              refresh_token="tGzv3JOkF0XG5Qx2TlKWIA",
                              example_parameter="example_value",
                              xscope=["inner", "outer"])

    token = Token(atr)
    grant.tokens.append(token)

    print grant.keys()
    assert _eq(grant.keys(), ['tokens', 'id_token', 'code', 'exp_in', 'seed',
                              'grant_expiration_time'])
    print token.keys()
    assert _eq(token.keys(), ['token_expiration_time', 'access_token',
                              'expires_in', 'example_parameter', 'token_type',
                              'xscope', 'refresh_token', 'scope',
                              'replaced'])

    assert token.access_token == "2YotnFZFEjr1zCsicMWpAA"
    assert token.token_type == "example"
    assert token.refresh_token == "tGzv3JOkF0XG5Qx2TlKWIA"
    assert token.example_parameter == "example_value"
    assert token.xscope == ["inner", "outer"]
    assert token.token_expiration_time != 0

    time.sleep(2)
    assert token.is_valid() is False
开发者ID:dajiaji,项目名称:pyoidc,代码行数:34,代码来源:test_oauth2.py

示例5: test_construct_access_token_req_expired_grant

# 需要导入模块: from oic.oauth2 import Grant [as 别名]
# 或者: from oic.oauth2.Grant import add_code [as 别名]
    def test_construct_access_token_req_expired_grant(self):
        resp = AuthorizationResponse(code="code", state="state")
        grant = Grant(-10)  # expired grant
        grant.add_code(resp)

        client = Client()
        client.grant["openid"] = grant
        with pytest.raises(GrantExpired):
            client.construct_AccessTokenRequest(state="openid")
开发者ID:joostd,项目名称:pyoidc,代码行数:11,代码来源:test_oauth2.py

示例6: test_client_get_grant

# 需要导入模块: from oic.oauth2 import Grant [as 别名]
# 或者: from oic.oauth2.Grant import add_code [as 别名]
def test_client_get_grant():
    cli = Client()

    resp = AuthorizationResponse(code="code", state="state")
    grant = Grant()
    grant.add_code(resp)

    cli.grant["state"] = grant

    gr1 = cli.grant_from_state("state")

    assert gr1.code == "code"
开发者ID:dajiaji,项目名称:pyoidc,代码行数:14,代码来源:test_oauth2.py

示例7: test_get_access_token_request

# 需要导入模块: from oic.oauth2 import Grant [as 别名]
# 或者: from oic.oauth2.Grant import add_code [as 别名]
def test_get_access_token_request():
    resp = AuthorizationResponse(code="code", state="state")
    grant = Grant(1)
    grant.add_code(resp)

    client = Client()
    client.grant["openid"] = grant
    time.sleep(2)
    try:
        client.construct_AccessTokenRequest(state="openid")
    except Exception, err:
        assert err.__class__.__name__ == "GrantExpired"
开发者ID:dajiaji,项目名称:pyoidc,代码行数:14,代码来源:test_oauth2.py

示例8: test_grant_resp

# 需要导入模块: from oic.oauth2 import Grant [as 别名]
# 或者: from oic.oauth2.Grant import add_code [as 别名]
def test_grant_resp():
    resp = AuthorizationResponse(code="code", state="state")
    grant = Grant()
    grant.add_code(resp)

    assert grant.code == "code"
    assert grant.grant_expiration_time != 0

    grant = Grant(1)
    grant.add_code(resp)
    time.sleep(2)

    assert grant.is_valid() is False

    grant = Grant.from_code(resp)
    assert grant.code == "code"
    assert grant.grant_expiration_time != 0
开发者ID:dajiaji,项目名称:pyoidc,代码行数:19,代码来源:test_oauth2.py

示例9: test_grant_access_token_2

# 需要导入模块: from oic.oauth2 import Grant [as 别名]
# 或者: from oic.oauth2.Grant import add_code [as 别名]
def test_grant_access_token_2():
    resp = AuthorizationResponse(code="code", state="state")
    grant = Grant()
    grant.add_code(resp)

    atr = AccessTokenResponse(access_token="2YotnFZFEjr1zCsicMWpAA",
                              token_type="example",
                              refresh_token="tGzv3JOkF0XG5Qx2TlKWIA",
                              example_parameter="example_value",
                              scope=["inner", "outer"])

    grant.add_token(atr)

    assert len(grant.tokens) == 1
    time.sleep(2)
    token = grant.tokens[0]
    assert token.is_valid() is True

    assert "%s" % grant != ""
开发者ID:dajiaji,项目名称:pyoidc,代码行数:21,代码来源:test_oauth2.py


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