Skip to content

Isuruvh/auth0-flask-app

Repository files navigation

🔐 Auth0 + Flask Authentication App

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.


🚀 Features

  • 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 .env configuration

📁 Project Structure

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


🔧 Installation & Setup

1. Clone the repository

git clone https://github.com/Isuruvh/auth0-flask-app.git cd auth0-flask-app

2. Create a virtual environment

python -m venv venv source venv/bin/activate # macOS/Linux venv\Scripts\activate # Windows

3. Install dependencies


🔐 Auth0 Configuration

  1. Log in to your Auth0 dashboard
  2. Create a new Regular Web Application
  3. Set the following URLs:

Allowed Callback URLs http://localhost:5000/callback

Allowed Logout URLs http://localhost:5000

Allowed Web Origins http://localhost:5000


🧩 Environment Variables

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 .env to GitHub.


▶️ Running the App

python app. Then open:

http://localhost:5000

You should see the login button, and after authenticating, your user profile.


📸 Example Output

After logging in, the app displays:

  • Name
  • Email
  • Profile picture
  • Raw user profile JSON

🛠️ Technologies Used

  • Python 3
  • Flask
  • Authlib
  • Auth0
  • OAuth2 / OpenID Connect

📄 License

This project is open-source and available under the MIT License.


⭐ Contributing

Pull requests are welcome.
For major changes, please open an issue first to discuss what you’d like to modify.


🙌 Author

Isuru Heendeniya
IAM Engineer | Cloud Automation | Python | Auth0 | Azure
GitHub: https://github.com/Isuruvh

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors