本文整理汇总了Python中oic.oauth2.Client.client_secret方法的典型用法代码示例。如果您正苦于以下问题:Python Client.client_secret方法的具体用法?Python Client.client_secret怎么用?Python Client.client_secret使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oic.oauth2.Client
的用法示例。
在下文中一共展示了Client.client_secret方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bearer_header_with_http_args
# 需要导入模块: from oic.oauth2 import Client [as 别名]
# 或者: from oic.oauth2.Client import client_secret [as 别名]
def test_bearer_header_with_http_args():
client = Client("A")
client.client_secret = "boarding pass"
request_args = {"access_token": "Sesame"}
cis = ResourceRequest()
bh = BearerHeader(client)
http_args = bh.construct(cis, request_args, http_args={"foo": "bar"})
print cis
print http_args
assert _eq(http_args.keys(), ["foo", "headers"])
assert http_args["headers"] == {"Authorization": "Bearer Sesame"}
# -----------------
request_args = {"access_token": "Sesame"}
bh = BearerHeader(client)
http_args = bh.construct(cis, request_args,
http_args={"headers": {"x-foo": "bar"}})
print cis
print http_args
assert _eq(http_args.keys(), ["headers"])
assert _eq(http_args["headers"].keys(), ["Authorization", "x-foo"])
assert http_args["headers"]["Authorization"] == "Bearer Sesame"
示例2: test_bearer_body
# 需要导入模块: from oic.oauth2 import Client [as 别名]
# 或者: from oic.oauth2.Client import client_secret [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
示例3: test_client_secret_post
# 需要导入模块: from oic.oauth2 import Client [as 别名]
# 或者: from oic.oauth2.Client import client_secret [as 别名]
def test_client_secret_post():
client = Client("A")
client.client_secret = "boarding pass"
cis = AccessTokenRequest(code="foo", redirect_uri="http://example.com")
csp = ClientSecretPost(client)
http_args = csp.construct(cis)
print cis
assert cis["client_id"] == "A"
assert cis["client_secret"] == "boarding pass"
print http_args
assert http_args is None
cis = AccessTokenRequest(code="foo", redirect_uri="http://example.com")
request_args = {}
http_args = csp.construct(cis, request_args,
http_args={"client_secret": "another"})
print cis
assert cis["client_id"] == "A"
assert cis["client_secret"] == "another"
print http_args
assert http_args == {}
示例4: test_client_secret_basic
# 需要导入模块: from oic.oauth2 import Client [as 别名]
# 或者: from oic.oauth2.Client import client_secret [as 别名]
def test_client_secret_basic():
client = Client("A")
client.client_secret = "boarding pass"
cis = AccessTokenRequest(code="foo", redirect_uri="http://example.com")
http_args = oauth2.client_secret_basic(client, cis)
assert http_args == {"auth": ("A", "boarding pass")}
示例5: test_client_secret_basic
# 需要导入模块: from oic.oauth2 import Client [as 别名]
# 或者: from oic.oauth2.Client import client_secret [as 别名]
def test_client_secret_basic():
client = Client("A")
client.client_secret = "boarding pass"
cis = AccessTokenRequest(code="foo", redirect_uri="http://example.com")
csb = ClientSecretBasic(client)
http_args = csb.construct(cis)
assert http_args == {"headers": {'Authorization': 'Basic %s'
% base64.b64encode('A:boarding pass')}}
示例6: test_bearer_header_2
# 需要导入模块: from oic.oauth2 import Client [as 别名]
# 或者: from oic.oauth2.Client import client_secret [as 别名]
def test_bearer_header_2():
client = Client("A")
client.client_secret = "boarding pass"
cis = ResourceRequest(access_token="Sesame")
http_args = oauth2.bearer_header(client, cis)
print cis
assert "access_token" not in cis
print http_args
assert http_args == {"headers": {"Authorization": "Bearer Sesame"}}
示例7: test_bearer_header
# 需要导入模块: from oic.oauth2 import Client [as 别名]
# 或者: from oic.oauth2.Client import client_secret [as 别名]
def test_bearer_header():
client = Client("A")
client.client_secret = "boarding pass"
request_args = {"access_token": "Sesame"}
cis = ResourceRequest()
bh = BearerHeader(client)
http_args = bh.construct(cis, request_args)
print cis
print http_args
assert http_args == {"headers": {"Authorization": "Bearer Sesame"}}
示例8: test_bearer_body_get_token
# 需要导入模块: from oic.oauth2 import Client [as 别名]
# 或者: from oic.oauth2.Client import client_secret [as 别名]
def test_bearer_body_get_token():
client = Client("A")
client.client_secret = "boarding pass"
client.state = "state"
resp1 = AuthorizationResponse(code="auth_grant", state="state")
client.parse_response(AuthorizationResponse, resp1.to_urlencoded(), "urlencoded")
resp2 = AccessTokenResponse(access_token="token1", token_type="Bearer", expires_in=0, state="state")
client.parse_response(AccessTokenResponse, resp2.to_urlencoded(), "urlencoded")
cis = ResourceRequest()
oauth2.bearer_body(client, cis)
assert "access_token" in cis
assert cis["access_token"] == "token1"
示例9: test_bearer_header_3
# 需要导入模块: from oic.oauth2 import Client [as 别名]
# 或者: from oic.oauth2.Client import client_secret [as 别名]
def test_bearer_header_3():
client = Client("A")
client.client_secret = "boarding pass"
client.state = "state"
resp1 = AuthorizationResponse(code="auth_grant", state="state")
client.parse_response(AuthorizationResponse, resp1.to_urlencoded(), "urlencoded")
resp2 = AccessTokenResponse(access_token="token1", token_type="Bearer", expires_in=0, state="state")
client.parse_response(AccessTokenResponse, resp2.to_urlencoded(), "urlencoded")
cis = ResourceRequest()
http_args = oauth2.bearer_header(client, cis)
print cis
assert "access_token" not in cis
print http_args
assert http_args == {"headers": {"Authorization": "Bearer token1"}}
示例10: test_client_secret_jwt
# 需要导入模块: from oic.oauth2 import Client [as 别名]
# 或者: from oic.oauth2.Client import client_secret [as 别名]
def test_client_secret_jwt():
cli = Client("Foo")
cli.token_endpoint = "https://example.com/token"
cli.client_secret = "foobar"
csj = ClientSecretJWT(cli)
cis = AccessTokenRequest()
http_args = csj.construct(cis, algorithm="HS256")
print http_args
assert cis["client_assertion_type"] == JWT_BEARER
assert "client_assertion" in cis
cas = cis["client_assertion"]
_jwt = JWT().unpack(cas)
jso = json.loads(_jwt.part[1])
assert _eq(jso.keys(), ["aud", "iss", "sub", "jti", "exp", "iat"])
print _jwt.headers
assert _jwt.headers == {'alg': 'HS256'}
_rj = JWS()
info = _rj.verify_compact(cas, [SYMKey(key=cli.client_secret)])
assert _eq(info.keys(), ["aud", "iss", "sub", "jti", "exp", "iat"])
示例11: test_client_secret_jwt
# 需要导入模块: from oic.oauth2 import Client [as 别名]
# 或者: from oic.oauth2.Client import client_secret [as 别名]
def test_client_secret_jwt():
cli = Client("Foo")
cli.token_endpoint = "https://example.com/token"
cli.client_secret = "foobar"
csj = ClientSecretJWT(cli)
cis = AccessTokenRequest()
http_args = csj.construct(cis, algorithm="HS256")
print http_args
assert cis["client_assertion_type"] == JWT_BEARER
assert "client_assertion" in cis
cas = cis["client_assertion"]
header, claim, crypto, header_b64, claim_b64 = jwkest.unpack(cas)
jso = json.loads(claim)
assert _eq(jso.keys(), ["aud", "iss", "sub", "jti", "exp", "iat"])
print header
assert header == {'alg': 'HS256'}
_rj = JWS()
info = _rj.verify_compact(cas, [SYM_key(key=cli.client_secret)])
_dict = json.loads(info)
assert _eq(_dict.keys(), ["aud", "iss", "sub", "jti", "exp", "iat"])
示例12: client
# 需要导入模块: from oic.oauth2 import Client [as 别名]
# 或者: from oic.oauth2.Client import client_secret [as 别名]
def client():
cli = Client(**CLIENT_CONF)
cli.client_secret = "boarding pass"
return cli
示例13: client
# 需要导入模块: from oic.oauth2 import Client [as 别名]
# 或者: from oic.oauth2.Client import client_secret [as 别名]
def client():
cli = Client("A")
cli.client_secret = "boarding pass"
return cli