CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-google-auth-oauthlib

Google Authentication Library - oauthlib integration for OAuth 2.0 flows.

83

1.05x
Overview
Eval results
Files

task.mdevals/scenario-9/

OAuth 2.0 Token Manager

Build a simple token manager that handles OAuth 2.0 authorization flows for Google APIs.

Requirements

Your implementation should:

  1. Create an OAuth 2.0 flow from a client secrets configuration
  2. Generate an authorization URL for user consent
  3. Exchange an authorization code for access tokens
  4. Convert the OAuth session into Google credentials

The manager should work with the installed application flow pattern.

Test Cases

The implementation must pass the following test cases:

  • Creating a flow from a client configuration dictionary with auth_uri, token_uri, and client_id returns a valid Flow object @test
  • Generating an authorization URL from a valid flow returns a URL string and a state parameter @test
  • Exchanging a valid authorization response URL for tokens returns credentials with an access_token attribute @test

Implementation

@generates

API

def create_flow(client_config: dict, scopes: list[str], redirect_uri: str = "urn:ietf:wg:oauth:2.0:oob"):
    """
    Create an OAuth 2.0 flow from client configuration.

    Args:
        client_config: Dictionary with OAuth client settings
        scopes: List of OAuth 2.0 scopes to request
        redirect_uri: The redirect URI for the flow

    Returns:
        An OAuth flow object
    """
    pass

def get_authorization_url(flow):
    """
    Generate an authorization URL from a flow.

    Args:
        flow: An OAuth flow object

    Returns:
        Tuple of (authorization_url, state)
    """
    pass

def exchange_code_for_token(flow, authorization_response: str):
    """
    Exchange authorization code for access tokens.

    Args:
        flow: An OAuth flow object
        authorization_response: The authorization response URL

    Returns:
        Google credentials object with access token
    """
    pass

Dependencies { .dependencies }

google-auth-oauthlib { .dependency }

Provides OAuth 2.0 integration with Google's authentication library.

Install with Tessl CLI

npx tessl i tessl/pypi-google-auth-oauthlib

tile.json