To provide simple examples of implementing 2FA with Python.
Strictly speaking, FreeOTP isn't required for generating keys and QR codes for synchronization. It will, however, let you see first-hand how the system works from both ends. Any RFC 6238 compliant code generator that allows specifying a secret key will work for allowing you to test the codes generated by the scripts.
pip install -r requirements.txt
Generate a secret key and QR code with:
python 01-generate-key-qr.py
Import the secret key into FreeOTP manually or via the QR code import feature.
Run the code matching script with:
python 02-code-match.py
Enter the secret key generated in step 1 into the prompt.
Generate an OTP code within FreeOTP using the key you imported in step 2.
Enter the OTP code into the prompt.
If you took too long to copy the OTP code from FreeOTP, you'll get a mismatch error.
If you were reasonably quick about it (TOTP codes are valid within a 30 second window), you'll get a code match notice.