CertSession¶
Mutual-TLS requests.Session subclass for certificate-authenticated API sources.
- class scamander.api.cert_session.CertSession(cert: str | tuple[str, str], verify: bool | str = True)¶
Bases:
SessionA
requests.Sessionsubclass that authenticates via a mutual TLS client certificate, with no token lifecycle to manage.The certificate is applied to every request sent through the session, including through a mounted
ThrottledHTTPAdapter.- Parameters:
cert – Client-side certificate. Either a path to a combined PEM file or a
(cert, key)path tuple.verify – Server certificate verification. Pass a CA bundle path,
Trueto use the default CA store, orFalseto disable verification. Defaults toTrue.
Example:
from scamander.api import CertSession, ThrottledHTTPAdapter, RateLimiter session = CertSession( cert=("client.crt", "client.key"), verify="ca-bundle.pem", ) session.mount("https://", ThrottledHTTPAdapter( rate_limiter=RateLimiter(max_calls=300, period_secs=60), )) response = session.get("https://api.example.com/data")