Install & Compatibility
Where this runs
tested against v1.1.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 27.9MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 3.2s · import 0.000s · 28MB
26MB installed
● package 26MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
VonageError
✓ from vonage_utils import VonageError
✗ from vonage_utils.client import Client
format_phone_number
✓ from vonage_utils import format_phone_number
✗ from vonage_utils.client import Client
remove_none_values
✓ from vonage_utils import remove_none_values
✗ from vonage_utils.client import Client
This quickstart demonstrates how to use the `SignatureVerification` class from `vonage-utils` to validate incoming Vonage webhook requests. This is crucial for securing your webhooks by ensuring the payload originated from Vonage and has not been altered.
import os
from vonage_utils.signature import SignatureVerification
# Replace with your actual signature secret from Vonage API dashboard
# For example, store it in an environment variable named VONAGE_SIGNATURE_SECRET
VONAGE_SIGNATURE_SECRET = os.environ.get("VONAGE_SIGNATURE_SECRET", "YOUR_SIGNATURE_SECRET")
if VONAGE_SIGNATURE_SECRET == "YOUR_SIGNATURE_SECRET":
print("WARNING: Please set the VONAGE_SIGNATURE_SECRET environment variable or replace 'YOUR_SIGNATURE_SECRET' with your actual secret.")
# Example webhook payload (as a raw string, as received by your server)
webhook_payload = '{"msisdn":"1234567890","to":"19876543210","messageId":"00000000-0000-0000-0000-000000000000","text":"Hello World","type":"text","keyword":"HELLO","api-key":"YOUR_API_KEY","message-timestamp":"2023-10-27 10:00:00"}'
# Example X-Vonage-Signature header value received with the webhook
# This value is a hash calculated by Vonage based on the payload and your secret.
# (The example below is a placeholder; a real one would be dynamically generated.)
vonage_signature = "e10adc3949ba59abbe56e057f20f883e" # Placeholder: MD5 hash of "Hello World" for illustration
verifier = SignatureVerification(VONAGE_SIGNATURE_SECRET)
# To verify an incoming webhook signature
is_valid = verifier.check_signature(webhook_payload, vonage_signature)
if is_valid:
print("Signature is valid! The webhook can be trusted.")
else:
print("Signature is invalid! The webhook might be tampered with or is not from Vonage.")
# For actual production use:
# - Ensure VONAGE_SIGNATURE_SECRET is your correct secret.
# - `webhook_payload` must be the exact raw request body.
# - `vonage_signature` must be the exact value from the 'X-Vonage-Signature' HTTP header.
Upgrade
Version history
1.1.4latest on PyPI · released Oct 21, 2024
Audit
Dependencies
requestsrequiredUsed for making HTTP requests.
pyjwtrequiredUsed for JSON Web Token (JWT) handling.
cryptographyrequiredProvides cryptographic primitives, likely for signature verification.
pydanticrequiredUsed for data validation and parsing.