Check a verification code
Check the verification code that a user has provided. You should always check the verification code after sending it. This enables Vonage to determine the number of successful requests and protect against fraudulent use of the platform.
Where needed, replace the following variables in the sample code with your own values:
| Key | Description |
|---|---|
REQUEST_ID | The ID of the Verify request (this is returned in the API response when you send a verification code) |
JWT | Used to authenticate your request. See Authentication for more information, including how to generate a JWT. |
VONAGE_APPLICATION_PRIVATE_KEY_PATH | Private key path. |
VONAGE_APPLICATION_ID | The Vonage Application ID. |
CODE | The code the user supplies as having been sent to them |
Run your code
Save this file to your machine and run it:
Prerequisites
Create a file named checkCode.js and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
Create a file named CheckVerificationCode and add the following code to the main method:
val client = Vonage {
applicationId(VONAGE_APPLICATION_ID)
privateKeyPath(VONAGE_APPLICATION_PRIVATE_KEY_PATH)
}Write the code
Add the following to the main method of the CheckVerificationCode file:
if (client.verify.request(REQUEST_ID).isValidVerificationCode(CODE)) {
println("Code matches.")
}Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.verify with the package containing CheckVerificationCode:
Prerequisites
Add the following to build.gradle:
Create a file named CheckVerificationCode and add the following code to the main method:
Write the code
Add the following to the main method of the CheckVerificationCode file:
Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.verify2 with the package containing CheckVerificationCode:
Prerequisites
Create a file named VerifyCodeRequest.cs and add the following code:
Add the following to VerifyCodeRequest.cs:
Prerequisites
Create a file named send_code.php and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
Run your code
Save this file to your machine and run it:
Prerequisites
Create a file named check.rb and add the following code:
Run your code
Save this file to your machine and run it: