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

Class AssertionSession

authlib/integrations/requests_client/assertion_session.py:18–70  ·  view source on GitHub ↗

Constructs a new Assertion Framework for OAuth 2.0 Authorization Grants per :rfc:`7521`.

Source from the content-addressed store, hash-verified

16
17
18class AssertionSession(AssertionClient, Session):
19 """Constructs a new Assertion Framework for OAuth 2.0 Authorization Grants
20 per :rfc:`7521`.
21 """
22
23 token_auth_class = AssertionAuth
24 JWT_BEARER_GRANT_TYPE = JWTBearerGrant.GRANT_TYPE
25 ASSERTION_METHODS = {
26 JWT_BEARER_GRANT_TYPE: JWTBearerGrant.sign,
27 }
28 DEFAULT_GRANT_TYPE = JWT_BEARER_GRANT_TYPE
29
30 def __init__(
31 self,
32 token_endpoint,
33 issuer,
34 subject,
35 audience=None,
36 grant_type=None,
37 claims=None,
38 token_placement="header",
39 scope=None,
40 client_id=None,
41 default_timeout=None,
42 leeway=60,
43 **kwargs,
44 ):
45 Session.__init__(self)
46 self.default_timeout = default_timeout
47 update_session_configure(self, kwargs)
48 AssertionClient.__init__(
49 self,
50 session=self,
51 token_endpoint=token_endpoint,
52 issuer=issuer,
53 subject=subject,
54 audience=audience,
55 grant_type=grant_type,
56 claims=claims,
57 token_placement=token_placement,
58 scope=scope,
59 client_id=client_id,
60 leeway=leeway,
61 **kwargs,
62 )
63
64 def request(self, method, url, withhold_token=False, auth=None, **kwargs):
65 """Send request with auto refresh token feature."""
66 if self.default_timeout:
67 kwargs.setdefault("timeout", self.default_timeout)
68 if not withhold_token and auth is None:
69 auth = self.token_auth
70 return super().request(method, url, auth=auth, **kwargs)

Calls

no outgoing calls