tessl install tessl/pypi-google-auth-oauthlib@1.2.0Google Authentication Library - oauthlib integration for OAuth 2.0 flows.
Agent Success
Agent success rate when using this tile
83%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.05x
Baseline
Agent success rate without this tile
79%
Build a configuration manager for OAuth 2.0 authentication that supports loading client credentials from multiple sources.
Your task is to create a Python module that provides a flexible way to manage OAuth client configurations. The system should:
Support multiple configuration sources: Load OAuth client configuration from either JSON files or from Python dictionary objects passed directly in code.
Validate configurations: Ensure that any loaded configuration contains the required OAuth fields before use.
Create OAuth flows: Generate OAuth 2.0 authorization flows from the loaded configurations that can be used to authenticate users.
Handle both client types: Support both "web" and "installed" application client types in the configuration format.
The configuration should follow the standard Google OAuth client secrets format:
{
"web": {
"client_id": "your-client-id",
"client_secret": "your-client-secret",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token"
}
}or:
{
"installed": {
"client_id": "your-client-id",
"client_secret": "your-client-secret",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token"
}
}@generates
def load_config_from_file(file_path: str, scopes: list[str]) -> object:
"""
Load OAuth client configuration from a JSON file and create an OAuth flow.
Args:
file_path: Path to the client secrets JSON file
scopes: List of OAuth 2.0 scopes to request
Returns:
An OAuth flow object that can be used for authentication
"""
pass
def load_config_from_dict(config_dict: dict, scopes: list[str]) -> object:
"""
Load OAuth client configuration from a Python dictionary and create an OAuth flow.
Args:
config_dict: Dictionary containing client configuration in Google's format
scopes: List of OAuth 2.0 scopes to request
Returns:
An OAuth flow object that can be used for authentication
"""
pass
def get_authorization_url(flow: object) -> tuple[str, str]:
"""
Generate an authorization URL from an OAuth flow.
Args:
flow: An OAuth flow object
Returns:
A tuple of (authorization_url, state)
"""
passProvides OAuth 2.0 integration with Google's authentication library.