Below article would provide a high level overview of the integration steps for performing phone verification in India using 2Factor SMS OTP solution,
Here are 2 ways to implement it.
-
Implementing OTP logic with 2Factor API - Auto Generate OTP
Brief steps would be as below,
- Your application displays in input box, so end user can provide his phone number
- Once user clicks on Signup / Verify button, you would call our API Endpoint, to trigger an OTP to the end user
API Endpoint: ( Reference Here )
https://2factor.in/API/V1/{api_key}/SMS/{user's_phone_no}/AUTOGEN
Sample response:
{ "Status": "Success", "Details": "5D6EBEE6-EC04-4776-846D-3600422BD9EF" }
- Above step would send an OTP to the end user
- Now you would display another page / modal window / division, asking user to input the OTP value received
- Once user enters the OTP value and clicks on process / verify button, you would call below API Endpoint ( passing session id generated in Step 2 + Otp value entered by user in Step 4 )
API Endpoint: ( Reference Here )
https://2factor.in/API/V1/{api_key}/SMS/VERIFY/{session_id}/{otp_entered_by_user}
Sample Response:
{ "Status": "Success", "Details": "OTP Matched" }
- If the response received from our API says 'OTP Matched', then you can mark the user as verified in your database Else ask user to Retry.
-
Implementing OTP logic with 2Factor API - Manually Generate OTP
Brief steps would be as below,
- Your application displays in input box, so end user can provide his phone number
- Once user clicks on Signup / Verify button,
your program would generate a 4-6 digit random code and pass it to our API endpoint ( along with user's phone number ) to trigger an OTP to the end user
API Endpoint: ( Reference Here )
https://2factor.in/API/V1/{api_key}/SMS/{user's_phone_no}/{generated_otp}
Sample response:
{ "Status": "Success", "Details": "5D6EBEE6-EC04-4776-846D-3600422BD9EF" }
- Above step would send an OTP to the end user
- Now you would display another page / modal window / division, asking user to input the OTP value received
- Once user enters the OTP value and clicks on process / verify button, you would call below API Endpoint ( passing session id generated in Step 2 + Otp value entered by user in Step 4 )
API Endpoint: ( Reference Here )
https://2factor.in/API/V1/{api_key}/SMS/VERIFY/{session_id}/{otp_entered_by_user}
Sample Response:
{ "Status": "Success", "Details": "OTP Matched" }
- If the response received from our API says 'OTP Matched', then you can mark the user as verified in your database Else ask user to Retry.