Giter Club home page Giter Club logo

otp-in-django's Introduction

OTP-in-django

Quick and simple technique to implement the OTP functionality in your Django Project.

Python Packages required: pyotp, base64, django, django-rest-framework

API Calls

GET

This is to register the mobile number into the database and generate OTP.

http://127.0.0.1:8000/verify/9999999999/

POST

This is to verify the mobile number using OTP.

http://127.0.0.1:8000/verify/9999999999/

Data:

   {
    "otp":040301
   }

otp-in-django's People

Contributors

akash16s avatar rugvedb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

otp-in-django's Issues

getting error while verifying otp

While sending post request with otp getting below error

Internal Server Error: /verify/time_based/8530067675/
Traceback (most recent call last):
  File "/home/vishvajeet/vishvajeet/envs/dj/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/vishvajeet/vishvajeet/envs/dj/lib/python3.8/site-packages/django/core/handlers/base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/vishvajeet/vishvajeet/envs/dj/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/vishvajeet/vishvajeet/envs/dj/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/vishvajeet/vishvajeet/envs/dj/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/home/vishvajeet/vishvajeet/envs/dj/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/vishvajeet/vishvajeet/envs/dj/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/home/vishvajeet/vishvajeet/envs/dj/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/vishvajeet/vishvajeet/test/OTP-in-django/verification/views.py", line 89, in post
    if OTP.verify(request.data["otp"]):  # Verifying the OTP
KeyError: 'otp'

if I changed below (48) line in views.py then it is working fine. I am not getting otp as dictionary rather getting single number
if OTP.verify(request.data, Mobile.counter): # Verifying the OTP # request.data["otp"]

The same is true for time based otp verification

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.