Ctrl + K
DocumentationLog inGet started

tessl/pypi-google-auth-oauthlib

tessl install tessl/pypi-google-auth-oauthlib@1.2.0

Google 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%

task.mdevals/scenario-1/

OAuth Configuration Manager

Build a configuration manager for OAuth 2.0 authentication that supports loading client credentials from multiple sources.

Requirements

Your task is to create a Python module that provides a flexible way to manage OAuth client configurations. The system should:

  1. Support multiple configuration sources: Load OAuth client configuration from either JSON files or from Python dictionary objects passed directly in code.

  2. Validate configurations: Ensure that any loaded configuration contains the required OAuth fields before use.

  3. Create OAuth flows: Generate OAuth 2.0 authorization flows from the loaded configurations that can be used to authenticate users.

  4. Handle both client types: Support both "web" and "installed" application client types in the configuration format.

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"
  }
}

Implementation

@generates

API

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)
    """
    pass

Test Cases

  • Loading a valid client secrets JSON file creates a working OAuth flow @test
  • Loading configuration from a Python dictionary creates a working OAuth flow @test
  • Generated authorization URLs contain the correct client_id parameter @test
  • Both "web" and "installed" client types are supported @test

Dependencies { .dependencies }

google-auth-oauthlib { .dependency }

Provides OAuth 2.0 integration with Google's authentication library.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/google-auth-oauthlib@1.2.x
tile.json