Skip to main content
Version: Python

Number Verify Reference

To perform a number verification you need to the following steps:

  1. Initiate a number verification session: This is done on the user's device by following a URL provided by the service.
  2. Generate a token: This is done by the backend server once the user has initiated the session.
  3. Check the verification status: This is done by calling the service with the token generated in the previous step.

To initiate the process you use the NumberVerifyClient class. This class is accessible through the GlideClient instance. This can be run from the frontend or backend and only requires a client id and not a client secret. With the NumberVerifyClient instance you can call the getAuthUrl method to get the URL to start the verification process.

Once the user has followed the URL and initiated the session they will be redirected to your redirect URL with a code query parameter.

This code can the be used to create a NumberVerifyUserClient instance which will automatically exchange the code for an access token and allow you to call the verifyNumber method to check the verification status.

NumberVerifyClient Reference

Methods

1. getAuthUrl

Description: getAuthUrl retrieves the URL for the user to initiate a number verification session.

Syntax:

def get_auth_url(opts: NumberVerifyAuthUrlInput = {}) -> str:

Parameters:

ParameterTypeDescription
optsNumberVerifyAuthUrlInputAn object containing the auth URL options.

NumberVerifyAuthUrlInput Properties:

PropertyTypeDescription
statestringOptional - A state parameter to pass to the redirect URL.
useDevNumberstringOptional - A phone number to use for testing instead of using IP based routing (only works for sandbox numbers)

Returns:

  • string: The URL for the user to initiate a number verification session. This URL should be opened on the user's device.

Example:

from glide import GlideClient

def main():
glide = GlideClient()
url = glide.number_verify.get_auth_url()
print(f"Open this URL on the user's device: {url}")

if __name__ == "__main__":
main()

2. forUser

Description: forUser creates a NumberVerifyUserClient instance by providing the code received from the user's device. Optionally, you can provide a phone number to verify and then call the verifyNumber without providing the phone number again.

Syntax:

def for_user(params: NumberVerifyClientForParams) -> NumberVerifyUserClient:

Parameters:

ParameterTypeDescription
paramsNumberVerifyClientForParamsAn object containing the for parameters.

NumberVerifyClientForParams Properties:

PropertyTypeDescription
codestringThe code received from the user's device.
phoneNumberstringOptional - The phone number to verify.

Returns:

  • NumberVerifyUserClient: A NumberVerifyUserClient instance.

Example:

from glide import GlideClient

def main():
glide = GlideClient()
code = "code-from-user-device"
number_verify_user_client = glide.number_verify.for_user({
"code": code,
"phoneNumber": "+555123456789"
})

if __name__ == "__main__":
main()

NumberVerifyUserClient Reference

The NumberVerifyUserClient is used to interact with the Number Verify service for a specific phone number.

Methods

1. verifyNumber

Description: verifyNumber verifies that a the user's phone number matches the phone number provided.

Syntax:

def verify_number(params: NumberVerifyInput, conf: ApiConfig) -> NumberVerifyResponse:

Parameters:

ParameterTypeDescription
paramsNumberVerifyInputAn object containing the verification parameters.
confApiConfigAn object containing optional API configuration like session.

NumberVerifyInput Properties:

PropertyTypeDescription
phoneNumberstringThe phone number to verify. can be omitted if provided in the forUser method.

Returns:

  • NumberVerifyResponse: An object containing the verification status.

NumberVerifyResponse Properties:

PropertyTypeDescription
devicePhoneNumberVerifiedbooleanWhether the phone number is verified.

Example:

from glide import GlideClient

def main():
glide = GlideClient()
number_verify_user_client = glide.number_verify.for_user({
"code": "code-from-user-device",
"phoneNumber": "+555123456789"
})

number_verify_response = number_verify_user_client.verify_number()
if number_verify_response["devicePhoneNumberVerified"]:
print("Phone number verified")
else:
print("Phone number not verified")

if __name__ == "__main__":
main()

Error Handling

Each method in ExampleService can throw errors under certain conditions. Developers should handle these exceptions as part of their implementation. Common errors include:

  • InvalidInputError: Thrown when input parameters do not meet the required format or type.
  • OperationFailedError: Thrown when an operation cannot be completed successfully due to various issues, such as network problems or service unavailability.

Type Definitions

ApiConfig

This object can be sent to most service apis to override the default configuration like the access token used in the request.

Properties

PropertyTypeDescription
sessionSessionAn optional session object for authentication and authorization.

Session

This object represents a user session with an access token, expiration time, and associated scopes.

Properties

PropertyTypeDescription
accessTokenstringThe access token for the session.
expiresAtnumberThe expiration time of the session.
scopesstring[]An array of scopes associated with the session.