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
- Execute
gradle run
in your terminal. - Visit
http://localhost:3000
in your browser. - Enter your cell phone number with the international dialing code but omit the
+
symbol and any leading zeros. - Press the Register button. In a moment or two you should receive a verification code via SMS.
- Enter the verification code and press Check.
- 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.