arrow

Two-factor
authentication

Uploaded Date : 21 July 2022

30

20

2

Language:

Code Description

Two-factor authentication (2FA) can help protect your applications from password data leaks. Authentication with a one-time password (OTP) supplied by SMS to your users is an efficient method of implementing two-factor authentication. Premium direct routes from Auth Wiki ensure the highest possible delivery rates and the quickest possible delivery timeframes for your 2FA SMS messages.

Example

Two-factor authentication (2FA) can help protect your applications from password data leaks. Authentication with a one-time password (OTP) supplied by SMS to your users is an efficient method of implementing two-factor authentication. Premium direct routes from Auth Wiki ensure the highest possible delivery rates and the quickest possible delivery timeframes for your 2FA SMS messages.

Code

Use the Time-Based OTP algorithm to generate a random six-digit one-time password (OTP).

def send_verification_code_sms(self, dst_number: str, message): """
`send_verification_code` accepts destination number to which the message that has to be sent.
The message text should contain a `__code__` construct in the message text which will be replaced by the code generated before sending the SMS.
:param: dst_number :param: message :return: verification code """
try:
response = self.client.messages.create( src=self.app_number, dst=dst_number, text=message )
print(response)
return response
except exceptions as e:
print(e)
return "Error encountered", 400

Copy

Comments