tessl install tessl/pypi-requests-cache@1.2.0A persistent cache for python requests
Agent Success
Agent success rate when using this tile
76%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.27x
Baseline
Agent success rate without this tile
60%
A library that provides a cached OAuth-authenticated HTTP client for accessing protected API resources efficiently.
Build a client that authenticates using OAuth 2.0 and caches API responses. The client should integrate OAuth authentication with HTTP response caching.
Provide functionality to test the cached client using mocked HTTP responses, verifying that caching behavior works correctly without making real network requests.
@generates
class CachedOAuthClient:
"""
An OAuth 2.0 authenticated HTTP client with response caching.
This client manages OAuth token lifecycle and caches both tokens
and API responses to minimize network requests.
"""
def __init__(self, client_id: str, client_secret: str, token_url: str,
cache_name: str = 'oauth_cache', cache_backend: str = 'sqlite'):
"""
Initialize the cached OAuth client.
Args:
client_id: OAuth client identifier
client_secret: OAuth client secret
token_url: URL to fetch OAuth tokens from
cache_name: Name for the cache storage
cache_backend: Backend type for caching (default: 'sqlite')
"""
pass
def get(self, url: str, **kwargs) -> requests.Response:
"""
Make a GET request with OAuth authentication and response caching.
Args:
url: The URL to request
**kwargs: Additional arguments passed to requests
Returns:
Response object (may be from cache)
"""
pass
def clear_cache(self) -> None:
"""Clear all cached responses (but not tokens)."""
pass
def clear_token_cache(self) -> None:
"""Clear cached OAuth tokens."""
passProvides HTTP response caching capabilities with support for different storage backends and flexible cache management.
@satisfied-by
Provides OAuth 2.0 authentication support for requests library, handling token management and authenticated request signing.
@satisfied-by
Provides HTTP request mocking capabilities for testing, allowing simulation of API responses without network calls.
@satisfied-by