MCPcopy Create free account
hub / github.com/authlib/authlib / AssertionClient

Class AssertionClient

authlib/integrations/httpx_client/assertion_client.py:74–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72
73
74class AssertionClient(_AssertionClient, httpx2.Client):
75 token_auth_class = OAuth2Auth
76 oauth_error_class = OAuthError
77 JWT_BEARER_GRANT_TYPE = JWTBearerGrant.GRANT_TYPE
78 ASSERTION_METHODS = {
79 JWT_BEARER_GRANT_TYPE: JWTBearerGrant.sign,
80 }
81 DEFAULT_GRANT_TYPE = JWT_BEARER_GRANT_TYPE
82
83 def __init__(
84 self,
85 token_endpoint,
86 issuer,
87 subject,
88 audience=None,
89 grant_type=None,
90 claims=None,
91 token_placement="header",
92 scope=None,
93 client_id=None,
94 **kwargs,
95 ):
96 client_kwargs = extract_client_kwargs(kwargs)
97 httpx2.Client.__init__(self, **client_kwargs)
98
99 _AssertionClient.__init__(
100 self,
101 session=self,
102 token_endpoint=token_endpoint,
103 issuer=issuer,
104 subject=subject,
105 audience=audience,
106 grant_type=grant_type,
107 claims=claims,
108 token_placement=token_placement,
109 scope=scope,
110 client_id=client_id,
111 **kwargs,
112 )
113
114 def request(
115 self, method, url, withhold_token=False, auth=USE_CLIENT_DEFAULT, **kwargs
116 ):
117 """Send request with auto refresh token feature."""
118 if not withhold_token and auth is USE_CLIENT_DEFAULT:
119 if not self.token or self.token.is_expired():
120 self.refresh_token()
121
122 auth = self.token_auth
123 return super().request(method, url, auth=auth, **kwargs)

Callers 4

test_refresh_tokenFunction · 0.90
test_client_idFunction · 0.90
test_without_algFunction · 0.90

Calls

no outgoing calls

Tested by 4

test_refresh_tokenFunction · 0.72
test_client_idFunction · 0.72
test_without_algFunction · 0.72