better-auth-python

Verify JWTs for Python/FastAPI backends using Better Auth and JWKS.

1|Updated Feb 8, 2026
One-click install
npx skills add https://github.com/Mehakanis/Q4_todo_app --skill better-auth-python-mehakanis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-auth-python
Source: https://github.com/Mehakanis/Q4_todo_app/tree/main/.claude/skills/better-auth-python
Command: npx skills add https://github.com/Mehakanis/Q4_todo_app --skill better-auth-python-mehakanis

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

JWT verification for Python/FastAPI backends interacting with a Better Auth TypeScript server can be error-prone and repetitive. This skill provides reusable patterns for JWKS-based token verification, FastAPI dependencies, and secure protected routes, including ORM integration with SQLModel or SQLAlchemy.

Core Features & Use Cases

  • Simplified JWT verification workflow with a reusable get_current_user dependency for FastAPI endpoints.
  • Supports SQLModel and SQLAlchemy backends with templates for models, schemas, and protected routes.
  • Includes JWKS caching, robust error handling, and guidance for integrating Better Auth with frontend apps.

Quick Start

Install the required packages and wire get_current_user into your FastAPI app to enable JWT verification with Better Auth.

Frequently Asked Questions about better-auth-python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I verify Better Auth JWTs in a FastAPI backend?

To verify Better Auth JWTs in FastAPI, wire a reusable get_current_user dependency into protected endpoints. This handles token verification, JWKS key retrieval, and error handling while integrating with SQLModel or SQLAlchemy backends.

What is JWKS caching and how does it improve JWT validation?

JWKS caching stores signing keys retrieved from the JSON Web Key Set endpoint locally. This reduces network calls to the Better Auth server during token verification, improving protected route performance and avoiding rate limits.

Can I use SQLModel or SQLAlchemy for protected routes with Better Auth?

Yes, Better Auth JWT verification supports both SQLModel and SQLAlchemy backends. It provides reusable templates for database models, schemas, and FastAPI dependencies to seamlessly enforce protected routes with your chosen ORM.

How do I get the current user in FastAPI using Better Auth JWT?

You get the current user by injecting the get_current_user FastAPI dependency into your protected endpoints. It verifies the JWT via cached JWKS keys, handles validation errors, and returns the authenticated user object.

What is the best way to secure FastAPI endpoints with a TypeScript auth server?

The best way to secure FastAPI endpoints with a Better Auth TypeScript server is JWKS-based JWT verification. This stateless approach validates tokens via public signing keys, enabling secure protected routes without sharing private secrets.

Why does JWT verification fail when fetching signing keys via JWKS?

JWT verification via JWKS fails when the token is expired, the key ID is missing or mismatched, or network retrieval errors occur. The skill implements robust error handling to gracefully manage these validation failures in FastAPI.