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

OAuth Flow with Custom Redirect URI

Build a command-line tool that performs OAuth 2.0 authentication for Google APIs with a configurable redirect URI.

Requirements

Your tool should accept command-line arguments to configure the OAuth flow and must support custom redirect URI specification. The tool should:

  1. Accept a path to a client secrets JSON file
  2. Accept one or more OAuth scopes
  3. Accept a custom redirect URI as a parameter
  4. Create an OAuth flow using the provided configuration
  5. Generate and display the authorization URL
  6. Accept the authorization code from the user
  7. Exchange the code for credentials
  8. Display the obtained access token

Command-Line Interface

The tool should be invoked as follows:

python oauth_tool.py --client-secrets <path> --scopes <scope1> <scope2> --redirect-uri <uri>

Example:

python oauth_tool.py \
  --client-secrets client_secrets.json \
  --scopes https://www.googleapis.com/auth/drive.readonly \
  --redirect-uri http://localhost:9000/oauth2callback

Output Format

The tool should output:

  1. The authorization URL (labeled "Authorization URL:")
  2. A prompt asking the user to enter the authorization code
  3. The access token (labeled "Access Token:")

Test Cases

  • When given valid client secrets, scopes, and a redirect URI of "http://localhost:9000/callback", the flow should use that exact redirect URI @test
  • When creating the flow, if redirect URI is set to "https://example.com/auth", the authorization URL should contain the redirect_uri parameter with that value @test

Implementation

@generates

API

import argparse

def create_oauth_flow(client_secrets_path: str, scopes: list, redirect_uri: str):
    """
    Create an OAuth flow with the specified configuration.

    Args:
        client_secrets_path: Path to client secrets JSON file
        scopes: List of OAuth 2.0 scopes to request
        redirect_uri: Custom redirect URI for the OAuth flow

    Returns:
        Configured OAuth flow instance
    """
    pass

def main():
    """
    Main entry point for the OAuth tool.
    Parses command-line arguments and runs the OAuth flow.
    """
    pass

if __name__ == "__main__":
    main()

Dependencies { .dependencies }

google-auth-oauthlib { .dependency }

Provides OAuth 2.0 flow implementation for Google APIs with support for custom redirect URI configuration.

Version

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