Vonage Verify (Legacy)

1.0.1 · deprecated · verified Thu Apr 16

The `vonage-verify-legacy` package provides an interface for interacting with Vonage's older Verify API, which primarily supports 2FA via SMS and Voice channels. This library is part of the Vonage Python SDK monorepo and is explicitly marked as a legacy component, encouraging users to migrate to the newer Verify API. The current version is 1.0.1, and its release cadence is tied to the maintenance of the broader Vonage Python SDK, with a focus on deprecation rather than new features.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Vonage client using API key/secret (the legacy authentication method) and initiate a verification request using the `vonage-verify-legacy` package. It covers creating a `VerifyRequest` object and calling `start_verification`.

import os
from vonage import Vonage, Auth
from vonage_verify_legacy import VerifyRequest

# Configure your Vonage API key and secret (legacy authentication)
# For production, use environment variables: VONAGE_API_KEY, VONAGE_API_SECRET
API_KEY = os.environ.get('VONAGE_API_KEY', 'YOUR_API_KEY')
API_SECRET = os.environ.get('VONAGE_API_SECRET', 'YOUR_API_SECRET')

if API_KEY == 'YOUR_API_KEY' or API_SECRET == 'YOUR_API_SECRET':
    print("Please set VONAGE_API_KEY and VONAGE_API_SECRET environment variables or replace placeholders.")
    exit()

# Initialize the Vonage client using legacy API key/secret authentication
auth = Auth(api_key=API_KEY, api_secret=API_SECRET)
vonage_client = Vonage(auth=auth)

# Define verification parameters
params = {
    'number': '14155550100', # E.164 format
    'brand': 'MyCompany',
    'workflow_id': 1 # Default workflow for SMS then Voice
}

try:
    # Create a legacy VerifyRequest object
    request = VerifyRequest(**params)

    # Make the verification request using the legacy client
    response = vonage_client.verify_legacy.start_verification(request)

    if response.status == '0' or response.status == '00':
        print(f"Verification request successful. Request ID: {response.request_id}")
        # You can then prompt the user for the code and check it
        # vonage_client.verify_legacy.check(request_id=response.request_id, code='USER_CODE')
    else:
        print(f"Verification request failed: {response.error_text} (Status: {response.status})")
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →