{"id":24599871,"url":"https://github.com/utkarsh5026/pauth","last_synced_at":"2026-02-25T07:07:33.574Z","repository":{"id":249130923,"uuid":"830188782","full_name":"utkarsh5026/pauth","owner":"utkarsh5026","description":"An OAuth library for everyone in python","archived":false,"fork":false,"pushed_at":"2025-01-04T23:53:19.000Z","size":2916,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T06:35:56.982Z","etag":null,"topics":["facebook","github","google","lib","oauth2","package","pip","python","twitter"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pauth/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/utkarsh5026.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-17T19:19:21.000Z","updated_at":"2025-01-04T23:55:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"5ee159b9-7035-4d83-899b-687c7f39beab","html_url":"https://github.com/utkarsh5026/pauth","commit_stats":null,"previous_names":["utkarsh5026/pauth"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utkarsh5026%2Fpauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utkarsh5026%2Fpauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utkarsh5026%2Fpauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utkarsh5026%2Fpauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utkarsh5026","download_url":"https://codeload.github.com/utkarsh5026/pauth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251254259,"owners_count":21559791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["facebook","github","google","lib","oauth2","package","pip","python","twitter"],"created_at":"2025-01-24T13:17:56.841Z","updated_at":"2026-02-25T07:07:33.539Z","avatar_url":"https://github.com/utkarsh5026.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PAuth: Making OAuth 2.0 Authentication Simple\n\nWelcome to PAuth, a modern Python library that takes the complexity out of OAuth 2.0 authentication. Whether you're building a small Flask application or a large Django project, PAuth provides a clean, consistent, and secure way to handle authentication with popular OAuth providers.\n\n## Why PAuth?\n\nOAuth 2.0 implementation can be tricky. You need to manage authorization flows, handle tokens securely, validate states, and deal with different provider quirks. PAuth handles all of this for you while providing:\n\n- 🔐 **Complete OAuth 2.0 Implementation**: All the standard flows, with modern security features built in\n- 🌐 **Multiple Provider Support**: One consistent interface for all major OAuth providers\n- 🛠️ **Framework Integration**: Seamless integration with Flask and Django\n- 🔒 **Security First**: Built-in PKCE support, state validation, and secure token handling\n- 💡 **Developer-Friendly**: Clear APIs, comprehensive error handling, and TypeScript-style hints\n\n## Quick Start\n\nLet's get you authenticating in minutes:\n\n```bash\n# Basic installation\npip install pauth\n\n# With framework support\npip install pauth[flask]    # For Flask applications\npip install pauth[django]   # For Django applications\n```\n\n### Basic Usage\n\nHere's a simple example using Google OAuth:\n\n```python\nfrom pauth import OAuth2Client, Providers\n\n# Initialize the client\nclient = OAuth2Client(\n    provider=Providers.GOOGLE,\n    client_id=\"your_client_id\",\n    client_secret=\"your_client_secret\",\n    redirect_uri=\"https://your-app.com/callback\"\n)\n\n# Get the authorization URL\nauth_url = client.get_authorization_url(\n    scope=[\"openid\", \"email\", \"profile\"],\n    state=\"your_secure_state\"  # PAuth can generate this for you\n)\n\n# Later, in your callback handler...\ntokens = client.exchange_code(\n    code=\"authorization_code_from_callback\",\n    state=\"your_secure_state\"  # Validate the state\n)\n\n# Access user information\nuser_info = client.get_user_info(tokens.access_token)\n```\n\n### Flask Integration\n\nPAuth makes Flask integration smooth and simple:\n\n```python\nfrom flask import Flask, redirect, request\nfrom pauth.integrations.flask import FlaskOAuth\n\napp = Flask(__name__)\noauth = FlaskOAuth(\n    client_id=\"your_client_id\",\n    client_secret=\"your_client_secret\",\n    redirect_uri=\"http://localhost:5000/callback\"\n)\n\n@app.route('/login')\ndef login():\n    return redirect(oauth.get_authorization_url())\n\n@app.route('/callback')\ndef callback():\n    tokens = oauth.handle_callback(request)\n    user = oauth.get_user_info(tokens.access_token)\n    # Handle user login in your application\n    return f\"Welcome, {user.name}!\"\n```\n\n### Django Integration\n\nFor Django applications, PAuth provides a seamless experience:\n\n```python\n# settings.py\nINSTALLED_APPS = [\n    ...\n    'pauth.integrations.django',\n]\n\nPAUTH_CONFIG = {\n    'PROVIDERS': {\n        'google': {\n            'client_id': 'your_client_id',\n            'client_secret': 'your_client_secret',\n            'redirect_uri': 'http://localhost:8000/oauth/callback',\n        }\n    }\n}\n\n# urls.py\nfrom django.urls import path, include\n\nurlpatterns = [\n    path('oauth/', include('pauth.integrations.django.urls')),\n]\n\n# views.py\nfrom pauth.integrations.django import oauth\n\ndef login(request):\n    return oauth.redirect_to_provider('google')\n\ndef callback(request):\n    user_info = oauth.handle_callback(request)\n    # Handle user login in your application\n```\n\n## Advanced Features\n\n### PKCE Support\n\nPAuth implements PKCE (Proof Key for Code Exchange) for enhanced security:\n\n```python\nclient = OAuth2Client(\n    provider=Providers.GITHUB,\n    client_id=\"your_client_id\",\n    use_pkce=True  # Enable PKCE\n)\n\n# PAuth handles code verifier generation and challenge creation\nauth_url = client.get_authorization_url(scope=[\"user\"])\n```\n\n### Custom Token Storage\n\nImplement custom token storage for your specific needs:\n\n```python\nfrom pauth.storage import BaseTokenStorage\n\nclass RedisTokenStorage(BaseTokenStorage):\n    def __init__(self, redis_client):\n        self.redis = redis_client\n\n    def save_token(self, user_id: str, tokens: dict):\n        self.redis.hmset(f\"user:{user_id}:tokens\", tokens)\n\n    def get_token(self, user_id: str) -\u003e dict:\n        return self.redis.hgetall(f\"user:{user_id}:tokens\")\n\n    def delete_token(self, user_id: str):\n        self.redis.delete(f\"user:{user_id}:tokens\")\n\n# Use your custom storage\nclient = OAuth2Client(\n    provider=Providers.GOOGLE,\n    client_id=\"your_client_id\",\n    token_storage=RedisTokenStorage(redis_client)\n)\n```\n\n### Error Handling\n\nPAuth provides comprehensive error handling:\n\n```python\nfrom pauth.exceptions import (\n    AuthorizationError,\n    TokenError,\n    InvalidStateError,\n    ProviderError\n)\n\ntry:\n    tokens = client.exchange_code(code, state)\nexcept AuthorizationError as e:\n    # Handle authorization errors (e.g., invalid code)\n    print(f\"Authorization failed: {e}\")\nexcept TokenError as e:\n    # Handle token-related errors\n    print(f\"Token error: {e}\")\nexcept InvalidStateError as e:\n    # Handle state validation errors\n    print(f\"State validation failed: {e}\")\nexcept ProviderError as e:\n    # Handle provider-specific errors\n    print(f\"Provider error: {e}\")\n```\n\n\n## Future Development\n\nPAuth is actively developing new features:\n\n### Upcoming Providers\n- Microsoft OAuth integration\n- LinkedIn authentication\n- Discord OAuth support\n- Apple Sign-In\n\n### Framework Support\n- FastAPI integration\n- aiohttp support\n- Starlette compatibility\n\n### Enhanced Features\n- Automatic token refresh\n- Rate limiting support\n- More storage backends\n- Enhanced token encryption\n\n\n\n## License\n\nPAuth is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for details.\n\n## About the Author\n\nPAuth is created and maintained by Utkarsh Priyadarshi (utkarshpriyadarshi5026@gmail.com), a passionate developer focused on making authentication simpler and more secure for Python applications.\n\nNeed help or have questions? Feel free to:\n- Open an issue on GitHub\n- Send me an email\n- Join our Discord community\n\nYour feedback and contributions help make PAuth better for everyone!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futkarsh5026%2Fpauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futkarsh5026%2Fpauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futkarsh5026%2Fpauth/lists"}