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 |
Write the code
Add the following to check-verification-code.sh:
curl -X POST "https://api.nexmo.com/v2/verify/$VERIFY_REQUEST_ID" \
-H "Authorization: Bearer $JWT"\
-H 'Content-Type: application/json' \
-d $'{
"code": "'$VERIFY_CODE'"
}'Run your code
Save this file to your machine and run it:
Prerequisites
npm install @vonage/server-sdkCreate a file named check-verification-code.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:
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.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
Install-Package VonageCreate a file named VerifyCodeRequest.cs and add the following code:
Add the following to VerifyCodeRequest.cs:
Prerequisites
composer require vonage/clientCreate a file named send_code.php and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
pip install vonage python-dotenvRun your code
Save this file to your machine and run it:
Prerequisites
gem install vonageCreate a file named check.rb and add the following code:
Run your code
Save this file to your machine and run it: