- A Django library for phone number confirmation with twilio with phone number validation
For installing django-Rest-phonenumber-confirmation, just run this command in your shell
pip install django-Rest-phonenumber-confirmation
INSTALLED_APPS = (
# ...
'rest_framework',
'phonenumber_field',
'phonenumber_confirmation',
)
UNIQUE_PHONE_NUMBER = True
PHONE_CONFIRMATION_EXPIRE_MINUTES = 15
PHONENUMBER_DEFAULT_REGION = "Your region code"
PHONENUMBER_DB_FORMAT = ( 'INTERNATIONAL' or 'NATIONAL' )
# YOUR TWILIO INFORMATION
TWILIO_ACCOUNT_SID = 'xxxxxxxxxxx'
TWILIO_AUTH_TOKEN = 'xxxxxxxxxxx'
TWILIO_FROM_NUMBER = 'xxxxxxxxxxx'
python manage.py migrate
urlpatterns = [
# ...
path('phone-confirm/api/', include('phonenumber_confirmation.urls')),
]
Method: POST
Endpoint: /phone-number/sent/
Payload:
{ "phone": "PHONE NUMBER" }
Method: POST
Endpoint: /phone-number/confirmation/
Payload:
{ "pin": "PIN" }
Method: POST
Endpoint: /resend/<int:phonenumber_id>/confirmation/
Param : phonenumber_id = phone number object id