Install & Compatibility
Where this runs
tested against v1.0.2 · 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.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 48.1MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 4.8s · import 0.000s · 48MB
47MB installed
● package 47MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
NetworkAuth
✓ from vonage_network_auth import NetworkAuth
✗ from vonage_network_auth.client import Client
CreateOidcUrl
✓ from vonage_network_auth import CreateOidcUrl
OidcResponse
✓ from vonage_network_auth import OidcResponse
This example demonstrates how to initialize the `Client` with your Vonage OAuth2 credentials (Client ID and Client Secret) and retrieve an access token for a specified scope. Remember to replace placeholder values or set them as environment variables (VONAGE_CLIENT_ID, VONAGE_CLIENT_SECRET, VONAGE_SCOPE) for production use.
import os
from vonage_network_auth.client import Client
# Ensure these are set as environment variables or replace with actual credentials
client_id = os.environ.get("VONAGE_CLIENT_ID", "YOUR_CLIENT_ID")
client_secret = os.environ.get("VONAGE_CLIENT_SECRET", "YOUR_CLIENT_SECRET")
scope = os.environ.get("VONAGE_SCOPE", "network:quality_of_service") # Example scope
if not client_id or not client_secret or client_id == "YOUR_CLIENT_ID":
print("Error: VONAGE_CLIENT_ID and VONAGE_CLIENT_SECRET must be set.")
print("Please set environment variables or replace placeholders.")
else:
try:
client = Client(client_id, client_secret)
# Request an access token for the specified scope
token_response = client.get_access_token(scope)
access_token = token_response["access_token"]
expires_in = token_response["expires_in"]
print(f"Access Token obtained successfully. Starts with: {access_token[:10]}...")
print(f"Token expires in: {expires_in} seconds")
# If the API provides a refresh token (not all do, depending on scope/grant type)
# refresh_token = token_response.get("refresh_token")
# if refresh_token:
# print("Refresh Token also obtained.")
# # Example of refreshing the token:
# # refreshed_token_response = client.refresh_access_token(refresh_token, scope)
# # print(f"Refreshed Access Token: {refreshed_token_response['access_token'][:10]}...")
except Exception as e:
print(f"An error occurred: {e}")
# In a production application, handle specific authentication errors (e.g., InvalidGrant).
Upgrade
Version history
1.0.2latest on PyPI · released Nov 29, 2024
Audit
Dependencies
requestsrequiredUsed for making HTTP requests to the Vonage OAuth2 endpoint.
PyJWTrequiredUsed for working with JSON Web Tokens (JWTs) including decoding and validation.
cryptographyrequiredA dependency of PyJWT for cryptographic operations.