auth0-flask

Add session-based Auth0 authentication to Flask apps with async routes.

40|23|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/auth0/agent-skills --skill auth0-flask
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth0-flask
Source: https://github.com/auth0/agent-skills/tree/main/plugins/auth0-sdks/skills/auth0-flask
Command: npx skills add https://github.com/auth0/agent-skills --skill auth0-flask

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provides a complete, production-oriented workflow to add session-based authentication to Flask web applications, removing uncertainty about secure login, callback, profile, and logout flows.

Core Features & Use Cases

  • ServerClient Initialization: Guides configuring ServerClient with domain, client_id, client_secret, secret, and redirect_uri for secure OAuth/OIDC flows.
  • Session Stores: Shows stateless cookie sessions and stateful Redis-backed sessions via custom FlaskSessionStateStore and FlaskSessionTransactionStore implementations.
  • Async Routes & Security: Covers async Flask route handlers, session cookie hardening, JWE-encrypted session data, and best practices for environment-based secrets and callback configuration.
  • Use Case: Add secure login, profile, and logout to a server-rendered Flask app that needs short-term access tokens and optional API audience access.

Quick Start

Install required packages, create a .env with AUTH0_DOMAIN, AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET, AUTH0_SECRET, and AUTH0_REDIRECT_URI, wire the provided FlaskSessionStateStore and FlaskSessionTransactionStore into a single ServerClient instance, and add async login, callback, profile, and logout routes.

Frequently Asked Questions about auth0-flask

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

FAQPage Schema
How do I add session-based authentication to a Flask app using Auth0?

Session-based authentication in Flask is added by initializing a ServerClient with domain, client_id, client_secret, and redirect_uri, then wiring custom state and transaction stores to manage login, callback, profile, and logout routes.

Does this Auth0 Flask integration support async route handlers?

Yes, this Auth0 Flask integration fully supports async route handlers for login, callback, profile, and logout flows, allowing you to manage user sessions asynchronously in server-rendered web applications.

Can I use Redis for Auth0 session persistence in Flask?

Yes, you can implement stateful Redis-backed session persistence by creating a custom FlaskSessionStateStore and FlaskSessionTransactionStore, instead of using the default stateless cookie sessions.

How do I secure Auth0 session cookies with JWE encryption in Flask?

JWE-encrypted session data secures Auth0 session cookies by encrypting the session state, ensuring that sensitive user information stored in cookies remains protected during transmission.

What environment variables are required to configure Auth0 login flows in Flask?

Configuring Auth0 login flows requires environment variables including AUTH0_DOMAIN, AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET, AUTH0_SECRET, and AUTH0_REDIRECT_URI to securely initialize the ServerClient.

What is the best way to handle logout and profile routes for Auth0 server-rendered Flask apps?

The best way to handle logout and profile routes is by adding dedicated async routes managed by a single ServerClient instance, ensuring secure session termination and profile retrieval for server-rendered Flask apps.