Your First Verification
This guide will help you get started with the Number Verify API by going through the steps to perform your first verification.
Prerequisites
Before you begin, you need to have the following:
- subscribe to the Number Verify service, (guide here)
Step 1: Get your API Credentials
To get your API Credentials, you can go to the Number Verify Product Page and click on "Manage on Provider" to access the service dashboard. For a full guide on how to get your credentials, you can refer to the Registration guide.
Step 2: Create a new project
Create a new folder and enter the folder from a terminal.
mkdir number-verify-test
cd number-verify-test
Step 3: Set Up Python Environment and Install SDK
Create and activate a virtual environment, then install the required packages:
python -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
pip install glide-sdk httpx python-dotenv
Step 4: Perform a Verification
import asyncio
import httpx
from glide_sdk import GlideClient
async def main():
glide = GlideClient(
client_id="<GLIDE_CLIENT_ID>",
client_secret="<GLIDE_CLIENT_SECRET>"
)
phone_number = '+555123456789'
# Authenticate and get session token
auth_url = await glide.number_verify.get_auth_url(
use_dev_number=phone_number,
print_code=True
)
async with httpx.AsyncClient(follow_redirects=True) as client:
res = await client.get(auth_url)
code = res.json()['code']
user_client = await glide.number_verify.for_user(
code=code,
phone_number=phone_number
)
# Verify phone number
verification_res = await user_client.verify_number()
print(verification_res)
if __name__ == "__main__":
asyncio.run(main())
The code starts by generating an authentication URL to be used by the user's device to identify the device. print_code
is used to print the code for testing instead of the auth server redirecting to the registered callback URL.
The code then fetches the URL and extracts the code from the response. This code is then used to create a user client to verify the phone number. The verification response is then logged to the console.
Since we are using the test number +555123456789
, the authentication url can be simply fetched from the script instead of running from the user's device. In a real application, this URL would be opened on the user's mobile device.
To execute this you can run the following from a terminal in the directory of your code:
python main.py
Next Steps
Congratulations! You have successfully performed your first verification using the Number Verify API. Next, you can follow our 5-minute quickstart to deploying a test application using the Number Verify API.