skillfed

sanic-jwt

JWT oauth flow for Sanic

sanic-jwt v1.8.0 259.2K downloads/30d#8,416 on PyPI246
Permissive license MIT DORMANT released

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-jwt

uv

uv add sanic-jwt

poetry

poetry add sanic-jwt

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

sanic authentication jwtsanic oauth jwtjwt protection sanicsanic endpoint authorizationsanic jwt middlewaresanic oauth flowjwt sanic framework
jwt-authsanic-framework

More Security packages