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.
Getting Started:
Reference Documentation:
Security & Best Practices:
Contributing:
External Links:
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']}")