Flask-Dance
Doing the OAuth dance with style using Flask, requests, and oauthlib
What it is and what it does
Flask-Dance is a Flask extension that abstracts the OAuth consumer flow, letting you add OAuth-based login to your application with minimal boilerplate. It wraps requests, oauthlib, and requests-oauthlib to handle token exchange, refresh, and storage transparently. The package provides pre-configured blueprints for popular providers and a flexible API for custom providers.
By default, tokens are stored in Flask's session, but the package supports pluggable storage backends—most commonly SQLAlchemy for persistent database storage. This prevents users from losing authentication when clearing browser cookies. The library integrates with Flask-SQLAlchemy, Flask-Login, and Flask-Caching, making it a natural fit for larger Flask applications that already use those extensions.
Use it for:
- Add OAuth login to a Flask app without writing OAuth flow code from scratch.
- Implement persistent OAuth token storage in a database using the SQLAlchemy backend.
- Support multiple OAuth providers in a single Flask application.
- Integrate OAuth authentication with Flask-Login for user session management.
- Build a custom OAuth integration for a non-standard provider using the flexible API.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Flask-Dance simplifies OAuth authentication in Flask applications by providing pre-built integrations with multiple OAuth providers and handling the token exchange flow automatically.
Yes, for stable OAuth authentication needs in Flask apps. The package is mature, well-documented, and carries no known vulnerabilities. Dormant maintenance is acceptable here because OAuth flows are standardized and unlikely to require frequent updates. Install it if you need straightforward OAuth integration; avoid it only if you require active upstream development or support for very recent OAuth extensions.
Install
flask-dance on PyPI
pip
pip install flask-danceuv
uv add flask-dancepoetry
poetry add flask-danceInstalling Flask-Dance
Before you install
Low friction installation with a pure-Python wheel. Maintenance is dormant—last release was in March 2024—but the repository remains active with recent commits and no archived status. Suitable for stable use cases where OAuth integration doesn't need active development.
License in practice
Licensed under MIT (permissive), allowing unrestricted use, modification, and distribution in both open-source and commercial projects.
Quickstart
pip install Flask-Dance
from flask import Flask
from flask_dance.contrib.github import make_github_blueprint, github
app = Flask(__name__)
app.secret_key = "your-secret-key"
blueprint = make_github_blueprint(client_id="id", client_secret="secret")
app.register_blueprint(blueprint, url_prefix="/login")
if github.authorized:
resp = github.get("/user")
print(resp.json())
Requires Flask app configuration with a secret key and OAuth provider credentials (client_id and client_secret).
Verify before relying
- Whether the list of supported OAuth providers remains current given the dormant maintenance status.
- Performance characteristics when handling high-volume token storage and refresh scenarios.
- Compatibility with recent Flask and Werkzeug major versions beyond Python 3.7, 3.8, 3.9, 3.10.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — requests, oauthlib, requests-oauthlib, Flask, Werkzeug, urlobject |
| Maintenance | dormant — 892 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,235,885/month — #4,175 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flask_dance-7.1.0-py3-none-any.whl
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
flask-oidcAdds OpenID Connect authentication support to…
permissive · top 5,000 on PyPI
Flask-OAuthlibFlask-OAuthlib adds OAuth 1.0a and OAuth 2.0…
permissive · top 15,000 on PyPI
Flask-SecurityFlask-Security adds authentication,…
permissive · top 15,000 on PyPI
Flask-LoginFlask-Login handles user session management for…
permissive · top 1,000 on PyPI
Flask-SQLAlchemyFlask-SQLAlchemy integrates SQLAlchemy database…
permissive · top 1,000 on PyPI
oauthenticatorOAuthenticator provides OAuth2 login handlers…
permissive · top 15,000 on PyPI
Flask-Security-TooAdds user authentication, authorization, and…
permissive · top 15,000 on PyPI
oauthlibOAuthLib implements OAuth 1.0 and OAuth 2.0…
permissive · top 1,000 on PyPI
flask-appbuilderFlask App Builder is a framework that generates…
permissive · top 5,000 on PyPI
PyLTI1p3Implements the LTI 1.3 Advantage specification…
permissive · top 15,000 on PyPI