A minimal, fully working authentication flow built with Flask, Auth0, and Authlib.
This project demonstrates modern OAuth2 / OpenID Connect login, session handling, and user profile retrieval using Auth0 as the Identity Provider.
Perfect as a starter template for IAM, OAuth2, or Python-based identity integrations.
- Login with Auth0 (supports Google, Microsoft, username/password, etc.)
- Secure OAuth2 / OIDC flow using Authlib
- Session-based authentication in Flask
- User profile display (name, email, picture, metadata)
- Logout (local + Auth0 logout)
- Clean project structure ready for extension
- Works locally with
.envconfiguration
auth0-flask-app/ │ ├── app.py # Main Flask application ├── auth.py # Auth0 OAuth client setup ├── requirements.txt # Python dependencies ├── .env # Environment variables (NOT committed) ├── templates/ │ ├── index.html # Home page │ └── profile.html # User profile page └── static/ # CSS, images, assets
git clone https://github.com/Isuruvh/auth0-flask-app.git cd auth0-flask-app
python -m venv venv source venv/bin/activate # macOS/Linux venv\Scripts\activate # Windows
- Log in to your Auth0 dashboard
- Create a new Regular Web Application
- Set the following URLs:
Allowed Callback URLs http://localhost:5000/callback
Allowed Logout URLs http://localhost:5000
Allowed Web Origins http://localhost:5000
Create a .env file in the project root:
AUTH0_CLIENT_ID=your_client_id AUTH0_CLIENT_SECRET=your_client_secret AUTH0_DOMAIN=your-tenant-region.auth0.com APP_SECRET_KEY=your_flask_session_secret
⚠️ Never commit.envto GitHub.
python app. Then open:
You should see the login button, and after authenticating, your user profile.
After logging in, the app displays:
- Name
- Profile picture
- Raw user profile JSON
- Python 3
- Flask
- Authlib
- Auth0
- OAuth2 / OpenID Connect
This project is open-source and available under the MIT License.
Pull requests are welcome.
For major changes, please open an issue first to discuss what you’d like to modify.
Isuru Heendeniya
IAM Engineer | Cloud Automation | Python | Auth0 | Azure
GitHub: https://github.com/Isuruvh