sanic-jwt
JWT oauth flow for Sanic
What it is and what it does
Sanic JWT is an authentication library for the Sanic web framework that wraps JWT tokens to protect endpoints and enforce authentication scopes. It depends on pyjwt for token handling and is designed to be both quick to set up—requiring only initialization with an authenticate callback—and extensible for custom authorization logic.
The package provides a standard OAuth flow pattern: developers define an authenticate function, initialize the library with a Sanic app instance, and gain automatic protection on endpoints plus a built-in /auth endpoint for token issuance. It has been stable since its early releases but has not received updates since 2022-06-28, making it suitable for mature Sanic applications that do not require frequent framework upgrades.
Use it for:
- Protect Sanic API endpoints with JWT tokens and enforce role-based or scope-based access control.
- Add OAuth-style authentication to existing Sanic applications without writing custom token middleware.
- Customize authentication logic by defining your own authenticate callback to integrate with external identity providers.
- Manage session-like authentication in microservices using JWT tokens instead of server-side sessions.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Sanic JWT adds JWT-based authentication and authorization to Sanic web applications, protecting endpoints and managing authentication scopes through a configurable OAuth flow.
Yes, with conditions. The package is stable, has low install friction, carries a permissive MIT license, and has no known vulnerabilities. However, it is dormant—last updated in June 2022—so it is best suited for mature Sanic applications that do not require frequent framework upgrades. If you are using a recent Sanic version or expect active maintenance and updates, verify compatibility first or consider alternatives.
Install
sanic-jwt on PyPI
pip
pip install sanic-jwtuv
uv add sanic-jwtpoetry
poetry add sanic-jwtInstalling sanic-jwt
Before you install
Low install friction with a single runtime dependency (pyjwt). Maintenance is dormant—last release was 2022-06-28, though the repository remains active with a recent commit on 2024-10-13 and 246 stars. The package is marked Production/Stable but has not received updates in years.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install sanic-jwt
from sanic import Sanic
from sanic_jwt import Initialize
def my_authenticate(request, *args, **kwargs):
# Your authentication logic
pass
app = Sanic()
Initialize(app, authenticate=my_authenticate)
Verify before relying
- Whether the package works with Sanic versions released after 2022 or Python versions beyond 3.9.
- Current state of community support or whether security patches would be applied if vulnerabilities were discovered.
- Compatibility with async/await patterns in recent Sanic releases.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pyjwt |
| Maintenance | dormant — 1,508 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 259,207/month — #8,416 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sanic_jwt-1.8.0-py3-none-any.whl
Keywords: sanic, oauth, authentication, jwt
Tags
More Security packages
Provides Python bindings to the FreeDesktop.org…
permissive · top 1,000 on PyPI
msalMSAL for Python handles OAuth2 and OpenID…
permissive · top 1,000 on PyPI
joserfcjoserfc implements JOSE standards (JWS, JWE,…
permissive · top 1,000 on PyPI
AuthlibAuthlib provides a complete implementation of…
permissive · top 1,000 on PyPI
argon2-cffi-bindingsProvides low-level CFFI bindings to the…
permissive · top 1,000 on PyPI
adalADAL for Python authenticates applications with…
permissive · top 1,000 on PyPI
Flask-JWT-ExtendedAdds JSON Web Token (JWT) authentication to…
permissive · top 5,000 on PyPI
django-oauth-toolkitAdds OAuth2 authorization server capabilities…
permissive · top 5,000 on PyPI
axioms-fastapiAdds OAuth2/OIDC JWT token validation and…
permissive · top 15,000 on PyPI
sanic-extSanic Extensions adds OpenAPI documentation,…
permissive · top 15,000 on PyPI
sanic-testingProvides sync and async test clients for…
permissive · top 15,000 on PyPI
Sanic-CorsSanic-CORS is a Sanic extension that adds…
permissive · top 15,000 on PyPI
Flask-BasicAuthFlask-BasicAuth adds HTTP basic access…
permissive · top 15,000 on PyPI
httpx-authProvides authentication classes for httpx HTTP…
permissive · top 5,000 on PyPI
Flask-CognitoFlask-Cognito integrates AWS Cognito JWT…
permissive · top 15,000 on PyPI
dj-rest-authProvides drop-in REST API endpoints for user…
permissive · top 5,000 on PyPI