https://github.com/vonage/vonage-python-jwt
A JWT Generator for Python. Creates JWTs for use with Vonage APIs.
https://github.com/vonage/vonage-python-jwt
authentication jwt jwt-authentication token vonage
Last synced: 4 months ago
JSON representation
A JWT Generator for Python. Creates JWTs for use with Vonage APIs.
- Host: GitHub
- URL: https://github.com/vonage/vonage-python-jwt
- Owner: Vonage
- License: apache-2.0
- Created: 2023-06-01T13:06:08.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-18T14:17:31.000Z (over 1 year ago)
- Last Synced: 2025-01-03T08:47:33.265Z (6 months ago)
- Topics: authentication, jwt, jwt-authentication, token, vonage
- Language: Python
- Homepage: https://developer.vonage.com
- Size: 18.6 KB
- Stars: 2
- Watchers: 8
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# Vonage JWT Generator for Python
[](https://badge.fury.io/py/vonage-jwt)
[](https://github.com/Vonage/vonage-python-jwt/actions)
[](https://pypi.python.org/pypi/vonage-jwt)
[](https://github.com/ambv/black)This package provides functionality to generate a JWT in Python code.
It is used by the [Vonage Python SDK](https://github.com/Vonage/vonage-python-sdk).
- [Installation](#installation)
- [Generating JWTs](#generating-jwts)
- [Verifying a JWT signature](#verifying-a-jwt-signature)## Installation
Install from the Python Package Index with pip:
```bash
pip install vonage-jwt
```## Generating JWTs
This JWT Generator can be used implicitly, just by using the [Vonage Python SDK](https://github.com/Vonage/vonage-python-sdk) to make JWT-authenticated API calls.
It can also be used as a standalone JWT generator for use with Vonage APIs, like so:
### Import the `JwtClient` object
```python
from vonage_jwt.jwt import JwtClient
```### Create a `JwtClient` object
```python
jwt_client = JwtClient(application_id, private_key)
```### Generate a JWT using the provided application id and private key
```python
jwt_client.generate_application_jwt()
```Optional JWT claims can be provided in a python dictionary:
```python
claims = {'jti': 'asdfzxcv1234', 'nbf': now + 100}
jwt_client.generate_application_jwt(claims)
```## Verifying a JWT signature
You can use the `verify_jwt.verify_signature` method to verify a JWT signature is valid.
```python
from vonage_jwt.verify_jwt import verify_signatureverify_signature(TOKEN, SIGNATURE_SECRET) # Returns a boolean
```