From the course: Securing Django Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using Twilio to send an SMS code

Using Twilio to send an SMS code - Django Tutorial

From the course: Securing Django Applications

Start my 1-month free trial

Using Twilio to send an SMS code

- [Instructor] We're going to be using Twilio to send a two-factor SMS code. So we're going to to start by importing the trace function from the random model so that we can generate the SMS code. And we have to import the REST client for Twilio. And we already have a model here. So what we're going to do is create a class method to send the code. And we're passing in the class at the user and the phone number that we're going to send the code to. Before we do anything else, we need the account SID and the auth token. You can get the account SID and the auth token and the phone number from the Twilio Dashboard. You can sign up for a Twilio trial account and create an SMS account. You can paste in the account SID and auth token and then we can create the Twilio Client using the account SID and the auth token. We're going to generate the code using these digits. And we use choice to select random digit for a six-digit code.…

Contents