Skip to content

jciskey/python-2fa-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python 2FA Examples

Purpose

To provide simple examples of implementing 2FA with Python.

Requirements

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

Usage

Step 1

Generate a secret key and QR code with: python 01-generate-key-qr.py

Step 2

Import the secret key into FreeOTP manually or via the QR code import feature.

Step 3

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.

About

A set of simple 2FA examples implemented in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages