Last active
March 6, 2018 05:56
-
-
Save vivekrk1992/fca8ad2e288fe50c99340ea33e32151d to your computer and use it in GitHub Desktop.
django otp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
activate source | |
``` | |
pip install django-otp | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALLED_APPS = ( | |
... | |
'django_otp', | |
'django_otp.plugins.otp_totp', | |
'django_otp.plugins.otp_hotp', | |
'django_otp.plugins.otp_static', | |
... | |
) | |
MIDDLEWARE = ( | |
... | |
'django.contrib.messages.middleware.MessageMiddleware', | |
'django_otp.middleware.OTPMiddleware', | |
... | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
confirm are you activate your source python | |
python manage.py migrate | |
then the result will be like bellow | |
``` | |
Applying otp_hotp.0001_initial... OK | |
Applying otp_static.0001_initial... OK | |
Applying otp_totp.0001_initial... OK | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django_otp.oath import hotp | |
secret_key = b'1234567890123467890' | |
print(hotp(key=secret_key, counter=1, digits=6)) # this is otp | |
output: | |
``` | |
328385 | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment