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-10/

OAuth Credential Manager for Interactive Sessions

Build a credential manager for interactive Python environments that helps users authenticate with Google APIs.

Requirements

Create a Python module that provides a simple function to obtain Google OAuth credentials interactively. The function should:

  1. Accept client ID, client secret, and scopes as parameters
  2. Automatically set up a local server to receive OAuth callbacks
  3. Open the user's browser to complete authentication
  4. Return credentials ready for making authenticated API calls

The solution should be straightforward for interactive environments like Jupyter notebooks or IPython shells.

Test Cases

Test 1: Basic Authentication Flow { @test }

  • Given valid client credentials (client_id="test_client", client_secret="test_secret") and scopes (["https://www.googleapis.com/auth/drive.readonly"]), the function should return credentials with a valid access token @test

Test 2: Multiple Scopes Support { @test }

Test 3: Credentials Ready for API Usage { @test }

  • Given completed authentication, the returned credentials should contain access_token, refresh_token, token_uri, client_id, and client_secret attributes @test

Implementation

@generates

API

def get_credentials(client_id: str, client_secret: str, scopes: list[str]):
    """
    Obtain Google OAuth credentials interactively.

    This function simplifies the OAuth flow for interactive environments by:
    - Automatically finding an available local port for the redirect server
    - Opening the user's browser for authentication
    - Handling the OAuth callback
    - Returning ready-to-use credentials

    Args:
        client_id: The OAuth 2.0 client ID
        client_secret: The OAuth 2.0 client secret
        scopes: List of OAuth 2.0 scopes to request

    Returns:
        Credentials object ready for use with Google API client libraries
    """
    pass

Dependencies { .dependencies }

google-auth-oauthlib { .dependency }

Provides OAuth 2.0 integration for Google authentication flows, including interactive authentication utilities.

@satisfied-by

Install with Tessl CLI

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

tile.json