The `vonage-jwt` package provides tooling for generating JSON Web Tokens (JWTs) for Vonage APIs in Python. It is primarily utilized by the Vonage Python SDK for authentication but can also be used as a standalone library. The current version is 1.1.5, with its latest release uploaded on November 29, 2024, indicating a moderate release cadence.
pip install vonage-jwtVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `JwtClient` with your Vonage Application ID and private key, then generate an application-level JWT. It expects the application ID and private key path to be provided via environment variables for security. The private key content is read from the specified file path. Replace placeholders or set environment variables before running.
Ensure all JWT generation occurs server-side, and only the generated token is sent to the client if needed.
Verify that the `application_id` matches your Vonage application and the `private_key` is the correct, untampered key associated with it.
Ensure your server's system clock is synchronized with NTP. Validate JWTs for correct `iat`, `nbf` (not before), and `exp` (expiration) claims, typically handled by the library.
After generating new keys, explicitly save the application settings in the Vonage Dashboard.
Refer to the specific API documentation to confirm the expected value for the 'sub' claim. If 'sub' is required, ensure it is populated with the username.
Double-check your `application_id` and `private_key` for accuracy. Verify the private key file exists and its content is correct. Ensure the JWT hasn't expired prematurely due to clock skew.
Confirm you are using the correct `private.key` file for the specified `application_id`. Ensure there are no extra spaces or line breaks when reading the private key content.
Generate a new JWT. Ensure your server's time is synchronized. Review the JWT's claims (`iat`, `nbf`, `exp`) using a tool like jwt.io to confirm their validity.
Verify the `VONAGE_PRIVATE_KEY_PATH` environment variable or direct path in your code points to the actual location of your `private.key` file. Ensure the script has read permissions for the file.