Initiate an SMS PIN verification request with .NET 6.0
You can quickly see how the Verification API works by sending yourself an SMS PIN verification request.
In this guide you will learn:
What you need to know before you start
Before you can get started, you need the following already set up:
- Set all Verification API configuration settings.
- ASP.NET Core 6.0 or later SDK and ASP.NET Core Runtime and a familiarity with how to create an app.
- A mobile handset that can receive SMS messages.
Set up your ASP.NET Core 6.0 application
Create a new project folder and open a command prompt. Execute the following command to create a new ASP.NET Core 6.0 console application:
dotnet new console
This creates a new console application and project.
Modify your application
In your project folder, open theProgram.cs
file and paste the provided "Program.cs" code into the file, replacing all the existing content.This code makes a POST request to the Verification API /verifications endpoint which sends an SMS PIN verification request out to the _to
parameter in the body of the request.Fill in your parameters
Before you can run the code, you need to update some values so you can connect to your Sinch account. Update the following parameters with your own values:
Parameter | Your value |
---|---|
_key | The application key found on your Sinch dashboard. |
_secret | The application secret found on your Sinch dashboard. |
_to | This should be the number of the mobile handset you are using for this guide. |
Save the file.
Initiate your verification request
Now you can execute the code and initiate your verification request. Run the following command:
dotnet run
You should receive a text message to your mobile handset with a verification code. In a production scenario, this is the code that a user would enter into your app to verify their account.
Troubleshooting tip
If after running your app you receive a 5000 error response, you may have forgotten to save your file after adding your authentication values. This is an easy mistake to make! Try saving the file and running the app again.
Next steps
Now it's time to take the one time PIN code you just received and use it to verify the identity of the user by reporting the PIN code.
Additional resources
Learn more about the Verification API: