← Back to all products

OAuth & Auth Library

$39

Complete authentication library with OAuth2, JWT, RBAC, session management, and social login integration.

20 filesv1.0.0
PythonYAMLMarkdownJSONFastAPIFlaskRedis

Product Preview

Try the interactive reader and demo tools below, or get the full product with all content unlocked.

Interactive Reader (Free Preview) ⚙ Try Demo Tools Download Free Sample

File Structure 20 files

oauth-auth-library/ ├── LICENSE ├── README.md ├── configs/ │ └── auth_config.yaml ├── examples/ │ ├── fastapi_auth.py │ └── flask_auth.py ├── guides/ │ └── auth-security-guide.md ├── src/ │ └── auth/ │ ├── jwt_handler.py │ ├── mfa.py │ ├── middleware.py │ ├── oauth2_client.py │ ├── password.py │ ├── providers/ │ │ ├── base.py │ │ ├── github.py │ │ └── google.py │ ├── rbac.py │ └── session.py └── tests/ ├── test_jwt.py ├── test_oauth2.py └── test_rbac.py

Documentation Preview README excerpt

OAuth Auth Library

Production-ready authentication and authorization for Python web applications.

JWT tokens, OAuth2 flows, RBAC, MFA, and session management — all in one library.

[![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)](https://datanest.dev)

[![Python](https://img.shields.io/badge/python-3.9%2B-green.svg)](https://python.org)

[![License](https://img.shields.io/badge/license-MIT-purple.svg)](LICENSE)


What You Get

  • JWT Handler — Create, verify, refresh, and revoke tokens with RS256/HS256
  • Password Security — Argon2/bcrypt hashing with strength validation
  • OAuth2 Client — Authorization code, client credentials, and PKCE flows
  • Provider Integrations — Google and GitHub OAuth with extensible base class
  • RBAC — Role-based access control with permission decorators
  • Auth Middleware — Token extraction, verification, and user injection
  • Session Management — Redis-backed sessions with create/validate/revoke
  • Multi-Factor Auth — TOTP generation, verification, and recovery codes
  • Framework Examples — FastAPI and Flask integration patterns

File Tree


oauth-auth-library/
├── README.md
├── manifest.json
├── LICENSE
├── src/auth/
│   ├── jwt_handler.py
│   ├── password.py
│   ├── oauth2_client.py
│   ├── providers/
│   │   ├── base.py
│   │   ├── google.py
│   │   └── github.py
│   ├── rbac.py
│   ├── middleware.py
│   ├── session.py
│   └── mfa.py
├── configs/
│   └── auth_config.yaml
├── examples/
│   ├── fastapi_auth.py
│   └── flask_auth.py
├── tests/
│   ├── test_jwt.py
│   ├── test_oauth2.py
│   └── test_rbac.py
└── guides/
    └── auth-security-guide.md

Getting Started

Issue and verify JWT tokens

... continues with setup instructions, usage examples, and more.

Code Sample .py preview

src/auth/jwt_handler.py """JWT token handler: create, verify, refresh, and revoke with RS256/HS256. Provides a complete JWT lifecycle management class with support for access tokens, refresh tokens, token revocation, and custom claims. """ from __future__ import annotations import time import uuid from dataclasses import dataclass, field from typing import Any, Optional import jwt @dataclass class TokenPair: """Access and refresh token pair.""" access_token: str refresh_token: str token_type: str = "Bearer" expires_in: int = 3600 class JWTHandler: """JWT token handler supporting HS256 and RS256 algorithms. Usage: handler = JWTHandler(secret_key="secret", algorithm="HS256") token = handler.create_access_token(subject="user_1") payload = handler.verify_token(token) """ def __init__( self, secret_key: Optional[str] = None, algorithm: str = "HS256", public_key: Optional[str] = None, issuer: Optional[str] = None, audience: Optional[str] = None, secret: Optional[str] = None, expiry_minutes: int = 60, ) -> None: if secret_key is None and secret is not None: secret_key = secret self._secret_key = secret_key self._public_key = public_key self._algorithm = algorithm # ... 195 more lines ...