Twilio Authy Configuration in Grails/Gradle application

I am going to start a blog series on Authy (Best Rated 2FA (Two-Factor Authentication) App) using Twilio (Build software that communicates with everyone in the world). But before this, let’s see how to configure them in your application.

I am using Grails framework (v3.2.9) which is using Gradle as a build tool. I am also using grails spring security core plugin for authentication in my demo application.

Step1 —

Go to authy-java git repository and clone/download it. Run the following command to generate authy-java.jar jar as given in the file in the repository.

ant compress

Step2 —

Put this jar file in lib folder in the root folder of your project and add this in the dependency section in the build.gradle file.

compile files('lib/authy-java.jar')

Step3 —

Add Twilio dependency in the build.gradle file.

compile 'com.twilio.sdk:twilio:7.11.0'

Step4 —

To access twilio/authy services you need
* Twilio Account SID
* Twilio Auth Token

Twillio Account SID And Auth Token

* Twilio Phone Number

Twillio Phone Number

* Authy API Key

Authy API Key

Keep these keys in a common place like application.groovy or application.yml for easy management.
I have put them in my application.groovy file —

authy.accountSID = "MyAccountSID"
authy.authToken = "MyAuthToken"
authy.fromPhoneNumber = "MyPhoneNumber"
authy.apiKey = "MyApiKey"

That’s all you need to configure. In my next blog, we will see how to implement two-factor authentication via SMS.