This repo contains a reference python implementation for handling a PKCE sign in flow.
- Prepare Environment Variables: Copy
.env.template
to.env
and fill in with real values. - Create a Virtual Environment:
python3 -m venv venv
(Unix) orpython -m venv venv
(Windows) - Activate the Virtual Environment:
source venv/bin/activate
(Unix) orvenv\Scripts\activate
(Windows CMD/PowerShell) - Install Dependencies:
pip install -r requirements.txt
- Run the Flask App:
python app_full_login.py
- Initiate Login Flow: Visit
http://localhost:3000/login
in your browser.
Before starting the project setup, you need to configure the necessary environment variables. Copy the .env.template
file to a new file named .env
and update it with the actual values for your application:
DOMAIN = USER_POOL_DOMAIN_NAME
REGION = us-east-1
CLIENT_ID = CLIENT_ID
REDIRECT_URI = http://localhost:3000
This step is crucial for configuring your application's authentication flow properly.
A virtual environment is an isolated environment for Python projects. This allows you to manage dependencies for different projects separately. To create a virtual environment, navigate to your project's directory in the terminal and run:
# For Unix-like operating systems
python3 -m venv venv
# For Windows
python -m venv venv
This command creates a virtual environment named venv
in your project directory.
Before you install dependencies, you need to activate the virtual environment. Depending on your operating system, you can activate it by running one of the following commands in your terminal:
# For Unix-like operating systems
source venv/bin/activate
# For Windows (cmd.exe)
venv\Scripts\activate.bat
# For Windows (PowerShell)
venv\Scripts\Activate.ps1
Your project should have a requirements.txt
file listing all necessary Python packages. Install these packages by running:
pip install -r requirements.txt
This command reads the requirements.txt
file and installs all listed packages in your activated virtual environment.
With your virtual environment activated and all dependencies installed, you're now ready to run the Flask application that implements the PKCE sign-in flow.
To start the Flask application, simply execute the following command in your terminal:
python app_full_login.py
After starting the Flask app, you can initiate the login flow by opening a web browser and navigating to http://localhost:3000/login
. This URL triggers the PKCE sign-in flow defined in your Flask application.