Skip to main content
Version: Python

Quickstart

This guide will help you get started with the Number Verify API. You will learn how to initialize the SDK, and verify a phone number.

Number verification checks that a phone is really who they say they are by comparing the phone number to check with a mobile device's identity through a mobile access token.

Because of this the process is split into two steps:

  1. Retrieve a mobile access token: This is done by sending a request from the mobile device itself from the telecom operator's network.
  2. Verify the phone number: This is done by sending the mobile access token and the phone number to the telecom operator.

The flow is meant to be done on a mobile device, but for the sake of this guide, we will create a simple web server and deploy it to allow you to send a request from a mobile web browser.

Prerequisites

Before you begin, you need to have the following:

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: Initialize the SDK and Web Server

pip -m venv venv
source venv/bin/activate
pip install glide-sdk
pip install flask

Step 4: Create a web server

To retrieve a mobile access token you need to be able to perform a request from the mobile device itself. This can be done both in a mobile app or via a mobile web browser. In this example we will create a simple web server to encapsulate the process.

Create a new file index.py and initialize the SDK and create a web server.

index.py
from glide_sdk import GlideClient
from flask import Flask, request, jsonify

app = Flask(__name__)
glide = GlideClient()

@app.route("/")
def home():
return app.send_static_file("index.html")

@app.route("/getAuthUrl")
def get_auth_url():
phone_number = request.args.get("phoneNumber")
auth_url = glide.number_verify.get_auth_url(state=phone_number)
response = {
"authUrl": auth_url
}
return jsonify(response)

@app.route("/callback")
def callback():
code = request.args.get("code")
phone_number = request.args.get("state")
user_client = glide.number_verify.for_user({
"code": code,
"phoneNumber": phone_number
})
verify_res = user_client.verify_number()
return jsonify(verify_res)

if __name__ == "__main__":
app.run(port=3000)

Step 5: Create a simple HTML file

Create a new file index.html in the same folder as the web server.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Number Verify</title>
</head>
<body>
<h1>Number Verify</h1>
<input type="text" id="phoneNumber" placeholder="Phone Number">
<button id="getAuthUrl">Get Auth URL</button>
<script>
document.getElementById("getAuthUrl").addEventListener("click", async () => {
const phoneNumber = document.getElementById("phoneNumber").value;
const res = await fetch(`/getAuthUrl?phoneNumber=${phoneNumber}`);
const data = await res.json();
window.location.href = data.authUrl;
});
</script>
</body>
</html>

Step 6: Create Vercel configuration file

Create a new file vercel.json in the project root directory

{
"version": 2,
"builds": [
{
"src": "dist/index.js",
"use": "@vercel/node",
"config": { "includeFiles": ["dist/**"] }
}
],
"routes": [
{
"src": "/(.*)",
"dest": "dist/index.js"
}
]
}

Step 7: Deploy the web server

Since the webserver needs to be accessed from a mobile device on the mobile network you need to deploy the web server to a public server. This guide will walk through the process of deploying to Vercel but any hosted server with a domain will work.

Deploy to Vercel

  1. Install the Vercel CLI
npm install -g vercel
  1. Login to Vercel
vercel login
  1. Deploy the server
vercel --prod
  1. Follow the prompts to deploy the server

  2. Setup the environment variables

vercel env add GLIDE_CLIENT_ID production // Then prompt <YOUR_CLIENT_ID>
vercel env add GLIDE_CLIENT_SECRET production // Then prompt <YOUR_CLIENT_SECRET>
  1. Redeploy the server
vercel --prod

You should recieve a URL that you can access from your mobile device to start the number verification process.

Step 8: Configure the redirect URL

From the Number Verify Product Page you can click on "Manage on Provider" to access the service dashboard. Here you can configure the redirect URL to point to your deployed server.

To do this click on "Edit Form" button and add the URL of your deployed server to the "Redirect URL" field on the last tab of the configuration page.

The value should be <YOUR_REDIRECT_URL>/callback. You can obtain the value of your <YOUR_REDIRECT_URL> by running the following command:

vercel projects

Step 9: Verify a phone number

Open the URL of your deployed server on your mobile device and enter a phone number. Click "Get Auth URL" and you will be redirected to the operator's page to verify the phone number.

Once authenticated you will be redirected back to your server to the callback URL where it will verify the phone number.

Next Steps

Now that you have verified a phone number you can start integrating the number verification process into your application. For more information on the API you can refer to the API Reference.