Skip to main content
Version: Go

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:

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
go mod init number-verify-test

Step 3: Initialize the SDK and Web Server

go get github.com/GlideApis/sdk-go

Step 4: Perform a Verification

main.go
package main

import (
"github.com/GlideApis/sdk-go/pkg/glide"
"github.com/GlideApis/sdk-go/pkg/types"
"encoding/json"
"net/http"
"fmt"
)

func main() {
glideClient, err := glide.NewGlideClient(types.GlideSdkSettings{
ClientID: "<client_id>",
ClientSecret: "<client_secret>",
})
if err != nil {
// handle error
return
}
phoneNumber := "+555123456789"
authUrl, err := glideClient.NumberVerify.GetAuthURL(types.NumberVerifyAuthUrlInput{
UseDevNumber: phoneNumber,
PrintCode: true,
})
if err != nil {
// handle error
return
}
// Get verification code
codeRes, err := http.Get(authUrl)
if err != nil {
// handle error
return
}
defer codeRes.Body.Close()
var codeResStruct struct {
Code string `json:"code"`
}
if err := json.NewDecoder(codeRes.Body).Decode(&codeResStruct); err != nil {
// handle error
return
}
numberVerifyUserClient, err := glideClient.NumberVerify.For(types.NumberVerifyClientForParams{
Code: codeResStruct.Code,
PhoneNumber: &phoneNumber,
})
if err != nil {
// handle error
return
}
numberVerifyResponse, err := numberVerifyUserClient.VerifyNumber(nil, types.ApiConfig{})
if err != nil {
// handle error
return
}
fmt.Println("Number verification result:", numberVerifyResponse.DevicePhoneNumberVerified)
}

To execute this you can the following from a terminal in the directory of your code:

go run main.go