使用Django和Twilio通过SMS进行一次性用户身份验证 [英] One-Time User Authentication with SMS Using Django and Twilio

查看:92
本文介绍了使用Django和Twilio通过SMS进行一次性用户身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Django为正在创建的移动应用程序编写一个后端。我需要在用户首次通过SMS打开移动应用程序时对其进行身份验证,以确认它是真实的人。需要发生的情况如下:用户在应用程序中输入电话号码,服务器然后将带有身份验证码的SMS消息发送给用户,用户然后在应用程序中输入身份验证代码,服务器验证他们在应用程序中输入的密码与收到的密码相同通过短信。

I am writing a back-end in Django for a mobile app I am creating. I need to authenticate a user the first time they open the mobile app through SMS to verify it is a real person. What needs to happen is the following: user enters phone number in app, server then sends SMS message to user with authentication code, user then enters authentication code in app and server verifies that the code they entered in the app is the same one they received through SMS.

我需要在我的Django项目中使用Twilio。我只需要知道执行此操作的最佳方法是什么?这个(移动应用程序)的前端不是我要问的,我是在问应该在后端实现的代码。我正在努力寻找可以实现此目的的django-twilio集成的最新文档。

I need to use Twilio with my Django project. I just need to know what would be the best way to go about this? The front-end side of this (the mobile app) is not what I am asking about, I am asking about the code on the back-end that should be implemented. I am struggling to find up to date documentation for django-twilio integration that could do this.

推荐答案

Twilio的福音传教士和维护者-twilio此处。

Twilio evangelist and maintainer of django-twilio here.

您要构建的内容非常容易实现,我可以在此处为您概述步骤:

What you're looking to build is something very easy to do, I can outline the steps for you here:


  • 创建一个存储用户号码和生成的密码的Django模型

  • 创建新用户时,获取其号码和短信他们使用 Twilio REST API

  • 何时他们输入您发送给他们的密码,然后将其与数据库中存储的密码进行交叉引用。

  • 如果密码正确:请验证密码,如果不正确,请告诉他们这是错误的,并提供再次向他们发送短信。

  • Create a Django model that stores a user's number and a generated passcode
  • When a new user is created, take their number and SMS them the code using the Twilio REST API
  • When they enter the passcode you sent them, cross reference it with the one stored in the database.
  • If the number is right: verify them, if not, tell them it is wrong and offer to send them an SMS again.

我希望这很清楚,如果您还有其他疑问,请随时与保罗取得联系@ twilio.com

I hope that is clear, if you have any more questions, feel free to get in touch at paul@twilio.com

这篇关于使用Django和Twilio通过SMS进行一次性用户身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆