2FA Example using Java/Spark and the Verify API

This is the source code to accompany the Implementing Two-Factor Authentication (2FA) with Java and Spark blog post

Requirements

This application requires that you have the following installed locally:

  • IDE of your choice
  • the latest version of Java
  • Gradle

Additionally, to test the application, you must have a Vonage account. You can create a Vonage account for free or manage your Vonage account details at the Vonage Dashboard.

Installation and Usage

You can run this application by first cloning this repository locally and opening in your IDE.

Once you have downloaded a local copy, change into the directory of the application and you can now set up the API credentials for your Vonage account.

API Credentials

Inside the source code, add your Vonage API key and API Secret to the string values.

As always, make sure not to commit your sensitive API credential data to any public version control.

Running the Application

  1. Execute gradle run in your terminal.
  2. Visit http://localhost:3000 in your browser.
  3. Enter your cell phone number with the international dialing code but omit the + symbol and any leading zeros.
  4. Press the Register button. In a moment or two you should receive a verification code via SMS.
  5. Enter the verification code and press Check.
  6. If you have entered the code successfully, you should receive a message that reads "Registration successful". If not, you will receive a message that reads "Verification failed".

Contributing

We ❤️ contributions from everyone! If you see something that needs fixing, then please follow the GitHub Flow and we'll try to incorporate it.

License

This project is under the Apache 2.0 License.