better-auth-python

Verify Better Auth JWTs in Python/FastAPI backends using JWKS signature validation.

3|Updated Dec 14, 2025
One-click install
npx skills add https://github.com/Syedaashnaghazanfar/full-stack-todo-app --skill better-auth-python
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-auth-python
Source: https://github.com/Syedaashnaghazanfar/full-stack-todo-app/tree/main/.claude/skills/better-auth-python
Command: npx skills add https://github.com/Syedaashnaghazanfar/full-stack-todo-app --skill better-auth-python

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Developers building Python/FastAPI backends often struggle to securely verify tokens issued by a centralized Better Auth server. This skill provides a battle-tested pattern for validating JWTs via JWKS, protecting routes, and enforcing user context across services.

Core Features & Use Cases

  • JWKS-based JWT verification: fetches and caches public keys from the Better Auth server and validates tokens signed with RS256.
  • Protected routes integration: exposes a FastAPI dependency get_current_user that can protect APIs and enforce user identity.
  • ORM integration readiness: provides integration patterns for SQLModel and SQLAlchemy to scope data by the authenticated user.

Quick Start

Install the required packages and wire get_current_user in your FastAPI app. Then start your FastAPI server and call a protected route using a Better Auth JWT.

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 JWT tokens from Better Auth in a FastAPI backend?

JWT verification in FastAPI involves fetching public keys from Better Auth's JWKS endpoint, validating token signatures with RS256, and extracting user identity. This Skill provides JWKS caching, Bearer token parsing, and a get_current_user dependency to protect routes and enforce authenticated user context across your application.

Can I use Better Auth tokens with SQLModel or SQLAlchemy in FastAPI?

Yes. This Skill demonstrates integration patterns for scoping database queries by authenticated user identity. After validating the JWT, you extract the user ID from the token and use it to filter SQLModel or SQLAlchemy queries, ensuring each user accesses only their own data.

What's the best way to protect FastAPI routes with JWT authentication?

Use a FastAPI dependency that validates incoming Bearer tokens against the Better Auth JWKS endpoint before route execution. This Skill provides a ready-to-wire get_current_user dependency that performs signature validation, caches public keys, and returns the authenticated user for downstream use.

How does JWKS-based token validation work with FastAPI?

JWKS validation fetches the server's public key set once and caches it, then uses those keys to verify each token's RS256 signature without calling the auth server repeatedly. FastAPI dependencies intercept requests, decode and validate the Bearer token, and pass the user context to your route handlers.

Do I need to handle token refresh or expiration in FastAPI?

This Skill focuses on validating tokens at request time using JWT decode and expiration checks. Token refresh logic remains your responsibility; the Skill ensures expired or invalid tokens are rejected before your route executes.

What happens if the Better Auth JWKS endpoint is unavailable?

The Skill implements JWKS caching to serve previously fetched keys if the endpoint becomes temporarily unreachable. However, during cache miss or server restart, availability of the JWKS endpoint is required to validate new tokens; consider retry and fallback strategies for production resilience.