Welcome to GitHub OAuth Helperโ€™s documentation!๏ƒ

A secure, easy-to-use Python library and CLI tool for GitHub OAuth authentication. Handle GitHub OAuth flows without exposing secrets in your code.

Overview๏ƒ

The GitHub OAuth Helper is designed with security as a primary concern. It provides:

Security Features:

  • ๐Ÿ” No Hard-Coded Secrets: Uses environment variables exclusively

  • ๐Ÿ›ก๏ธ CSRF Protection: Built-in state parameter generation and verification

  • ๐ŸŒ Transport Security: Automatic HTTP/HTTPS handling with security modes

  • ๐Ÿ“ Token Safety: Secure token handling without logging sensitive data

Developer Experience:

  • ๐ŸŽจ Colored CLI: Beautiful, intuitive command-line interface

  • ๐Ÿ”ง Flexible Usage: Both programmatic API and CLI tool

  • ๐Ÿ Modern Python: Python 3.8+ with comprehensive type hints

  • ๐Ÿ“š Complete Documentation: Extensive guides and examples

Quick Start๏ƒ

Installation:

pip install gh-oauth-helper

CLI Usage:

# Set up environment
export GITHUB_CLIENT_ID="your_client_id"
export GITHUB_CLIENT_SECRET="your_client_secret"

# Generate authorization URL and open in browser
gh-oauth-helper auth --open

# Exchange code for token
gh-oauth-helper token --code YOUR_AUTH_CODE

# Test token validity
gh-oauth-helper test --token YOUR_ACCESS_TOKEN

Python API:

from gh_oauth_helper import GitHubOAuth

# Initialize OAuth helper (uses environment variables)
oauth = GitHubOAuth()

# Generate authorization URL
auth_url, state = oauth.generate_authorization_url(scopes=["user", "repo"])
print(f"Visit: {auth_url}")

# Exchange code for token (after user authorization)
token_data = oauth.exchange_code_for_token(code, state)
access_token = token_data["access_token"]

# Test the token
user_info = oauth.test_api_access(access_token)
print(f"Authenticated as: {user_info['login']}")

Indices and tables๏ƒ