Skip to main content

A Django app to support phone number verification using security code sent via SMS.

Project description

https://github.com/CuriousLearner/django-phone-verify/actions/workflows/main.yml/badge.svg?branch=master https://coveralls.io/repos/github/CuriousLearner/django-phone-verify/badge.svg?branch=master License https://static.pepy.tech/badge/django-phone-verify?period=total&units=international_system&left_color=black&right_color=darkgreen&left_text=Downloads https://img.shields.io/badge/Made%20with-Python-1f425f.svg https://img.shields.io/badge/Maintained%3F-yes-green.svg https://badge.fury.io/py/django-phone-verify.svg https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square

django-phone-verify is a Django app that enables simple phone number verification using a security code sent via SMS. It supports Twilio and Nexmo (Vonage) out of the box and is fully customizable to suit your backend needs.

Docs are available at https://www.sanyamkhurana.com/django-phone-verify/.

Features

  • 🔐 Verify phone numbers using SMS security codes

  • 🔧 Supports custom token length and expiration time

  • 🔄 Built-in support for Twilio and Nexmo (Vonage)

  • 🧩 Easily extensible via pluggable backends

  • ✅ Doesn’t interfere with your existing AUTH_USER_MODEL

  • 🚀 Ready-to-use API endpoints via Django REST Framework

  • 🛠 Can be used for multiple flows like signup, 2FA, marketing opt-in, etc.

Installation

Install the package with all supported backends:

pip install django-phone-verify[all]

Or install with just the backend you need:

pip install django-phone-verify[twilio]
pip install django-phone-verify[nexmo]

Configuration

  1. Add phone_verify to INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "phone_verify",
    ...
]
  1. Configure PHONE_VERIFICATION settings:

PHONE_VERIFICATION = {
    "BACKEND": "phone_verify.backends.twilio.TwilioBackend",  # or NexmoBackend
    "OPTIONS": {
        "SID": "fake",
        "SECRET": "fake",
        "FROM": "+14755292729",
        "SANDBOX_TOKEN": "123456",
    },
    "TOKEN_LENGTH": 6,
    "MESSAGE": "Welcome to {app}! Please use security code {security_code} to proceed.",
    "APP_NAME": "Phone Verify",
    "SECURITY_CODE_EXPIRATION_TIME": 3600,  # in seconds
    "VERIFY_SECURITY_CODE_ONLY_ONCE": False,
}

Note: To use Nexmo instead of Twilio, change the BACKEND path to:

"BACKEND": "phone_verify.backends.nexmo.NexmoBackend"

and in OPTIONS, use:

"KEY": "your-nexmo-key",
"SECRET": "your-nexmo-secret"

Usage

To get started using the app and integrating it into your own flow (DRF or non-DRF), check the following documentation:

Compatibility

  • Python 3.6+

  • Django 2.1+

  • Django REST Framework 3.9+

Contributing

Found a bug? Want to suggest an improvement or submit a patch? Pull requests are welcome! 🙌 Please check the contributing guide before you start.

License

This project is licensed under the GPLv3 license.

Changelog

See the full changelog here: 📄 CHANGELOG.rst

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_phone_verify-3.1.0.tar.gz (33.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_phone_verify-3.1.0-py3-none-any.whl (34.0 kB view details)

Uploaded Python 3

File details

Details for the file django_phone_verify-3.1.0.tar.gz.

File metadata

  • Download URL: django_phone_verify-3.1.0.tar.gz
  • Upload date:
  • Size: 33.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for django_phone_verify-3.1.0.tar.gz
Algorithm Hash digest
SHA256 128acc5ce0b3e2399dc8db809e81dab749c0b838777b0b199f917c74c950a897
MD5 75931e5bbc41882df72011d6b90b57c6
BLAKE2b-256 a8f0da0f7b7888295c694e49494a413bfe2d094b51917ed21f4ce617f21ff7e7

See more details on using hashes here.

File details

Details for the file django_phone_verify-3.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_phone_verify-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9332ed241987876130d3950102ac73ce64cbb6feea8da7c221a36417f9e1732f
MD5 ae5e5c5eee12daadd7bb7aeda42b032a
BLAKE2b-256 ad4c28c72b61c694b43fb3222467845fca95fca7d04c5e56bc95a0c52fa55630

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page