33 lines
621 B
Python
33 lines
621 B
Python
|
from twilio.rest import Client
|
||
|
from secrets import randbits
|
||
|
from constants import account_id, token
|
||
|
|
||
|
|
||
|
def connect_api():
|
||
|
account_sid = account_id
|
||
|
auth_token = token
|
||
|
client = Client(account_sid, auth_token)
|
||
|
return client
|
||
|
|
||
|
|
||
|
def generate_code():
|
||
|
bits = 16
|
||
|
code = randbits(range)
|
||
|
return code
|
||
|
|
||
|
|
||
|
def create_otp(receiver):
|
||
|
client = connect_api()
|
||
|
code = generate_code()
|
||
|
sender = "+18555345401"
|
||
|
message = "Your OTP code is {0}".format(code)
|
||
|
call = client.calls.create(to=receiver, from_=sender, body=message)
|
||
|
|
||
|
|
||
|
def main():
|
||
|
create_otp("")
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|