Skip to content

Instantly share code, notes, and snippets.

@pyaf
Created March 15, 2017 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pyaf/7a52b5d6c7e1a92285a4c3b81addc683 to your computer and use it in GitHub Desktop.
Save pyaf/7a52b5d6c7e1a92285a4c3b81addc683 to your computer and use it in GitHub Desktop.
Authy API functions
from django.conf import settings
import requests
def send_verfication_code(user):
data = {
'api_key': settings.AUTHY_KEY,
'via': 'sms',
'country_code': user.country_code,
'phone_number': user.phone_number,
}
url = 'https://api.authy.com/protected/json/phones/verification/start'
response = requests.post(url,data=data)
return response
def verify_sent_code(one_time_password, user):
data= {
'api_key': settings.AUTHY_KEY,
'country_code': user.country_code,
'phone_number': user.phone_number,
'verification_code': one_time_password,
}
url = 'https://api.authy.com/protected/json/phones/verification/check'
response = requests.get(url,data=data)
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment