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

OAuth Configuration Validator

Build a command-line tool that validates OAuth 2.0 client configuration files and generates authorization URLs for Google API access.

Requirements

Your tool should:

  1. Accept a path to a JSON client secrets file as a command-line argument
  2. Load and validate the client configuration from the file
  3. Create an OAuth 2.0 flow with the specified scopes: https://www.googleapis.com/auth/drive.readonly and https://www.googleapis.com/auth/userinfo.email
  4. Generate an authorization URL that requests offline access
  5. Output the authorization URL and state parameter to stdout in the format:
    Authorization URL: <url>
    State: <state>
  6. Handle errors gracefully, printing error messages to stderr and exiting with code 1 on failure

Implementation

Create a Python script oauth_validator.py that implements the above requirements. The script should accept a single command-line argument for the client secrets file path.

Dependencies { .dependencies }

google-auth-oauthlib { .dependency }

Provides OAuth 2.0 authorization flow support for Google APIs.

Test Cases

Test 1: Valid Configuration { @test }

Given a valid client secrets file test_client_secrets.json:

{
  "installed": {
    "client_id": "test_client_id.apps.googleusercontent.com",
    "client_secret": "test_secret",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "redirect_uris": ["http://localhost"]
  }
}

When running: python oauth_validator.py test_client_secrets.json

The output should contain:

  • A line starting with "Authorization URL: https://accounts.google.com/o/oauth2/auth"
  • A line starting with "State: " followed by a non-empty string
  • The authorization URL should include parameters for the requested scopes and offline access

Test 2: Missing File { @test }

When running: python oauth_validator.py nonexistent.json

The script should:

  • Print an error message to stderr
  • Exit with code 1

Test 3: Multiple Scopes in URL { @test }

Using the same valid configuration from Test 1, verify that the generated authorization URL includes both requested scopes in the URL parameters.

Version

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