Whatever project you do, a marketplace or a web app, you don’t want to waste your time on developing some features from scratch. Of course, you can, but why to spend your time on something already done? Like the Authy Phone Verification API for verifying user phone numbers in Ruby on Rails.
The API presented in the material of Phil Nash aimed to simplify your developer’s life. So, if you ever need to contact your application’s users by phone then it’s good practice to verify that the phone number they enter is in fact theirs. We will show you how to verify phone numbers in a Rails 5 application using the Authy Phone Verification API.
The process of verification will include:
1. The user enters three bits of information
- Phone number
- Country code
- Whether they want to verify by voice or SMS
2. Our application makes a request to the API to initiate the verification
3. The user receives a call or text message with a 4 digit code
4. The user enters that code into a form in the application
5. The code is sent off to the API, with the phone number and country code again, to verify
6. If it is correct then the user has verified the number
The challenge here is sending to the user the 4 digits for the verification process.
Make sure, you have Ruby and Rails installed. The author uses the latest Rails 5.1.2 and Ruby 2.4.1. Also for this, you will need several gems: open up the Gemfile and add authy and envyable. The rest of the procedure you will see in the original example set in the article we put in the beginning.
You can check the full code for this article on GitHub.