This sample repository demonstrates how to add authentication to a Python web app built with the Flask using Authgear.
Authgear acts as an IAM provider that is a gatekeeper to the resources you provide to customers as web and mobile applications, APIs, etc. The gatekeeper initiates authorization as outlined in OAuth 2.0. The addition of the OpenID Connect layer adds authentication to secure your users’ digital identities and your product.
Before you get started, you will need the following:
- A free Authgear account. Sign up if you don't have one already.
- Create Authgear OIDC Client App to use it as an OpenID Connect Provider.
- Make sure that Python 3.10 or above is installed on your machine.
- Download and Install Pip to manage project packages.
Start by cloning the project into your local machine:
git clone https://github.com/authgear/authgear-example-python-flask.git
Make the project directory your current working directory:
cd authgear-example-python-flask
Rename .env.example
to .env
and fill it with the client ID, client secret and your Authgear OIDC client app domain. Generate a suitable string for APP_SECRET_KEY
using openssl rand -hex 32 from your shell and also set it in the environment file.
Also, add the callback URL to the settings section of your Authgear client app.
Register http://localhost:3000/callback
as Authorized Redirect URIs
.
Run pip install -r requirements.txt
to install the dependencies and run python server.py
.
The app will be served at http://localhost:3000/.