Nexmo Python JWT Generator
Python class to assist with generating JWT tokens for use with the Nexmo API.
Learn more about Authenticating with JSON Web Tokens.
Installation
To install, run:
pip install nexmo-jwt
Usage
JWTokenGenerator is a python class that receives the application_id and private_key as required parameters in the constructor. Then a token is generated
using the generate_token() method.
By default the generated token expires after 15 minutes, but this option can be configured using the set_expiration_iat method.
Generating a JWT
To generate token the application_id claim and the private_key are required. Using Nexmo Account as an example, you could enter to the Applications section and select a specific application. From there you can copy the application_id and Generate a new Public key, And then download the private key file.
Generating a JWT with Private Key Contents
To generate a JWT with these properties you can use:
from nexmo_jwt import JWTokenGenerator
gen: JWTokenGenerator = JWTokenGenerator('your-application-id','private key contents')
token: bytes = gen.generate_token()
Generating a JWT with Private Key Path
You can also provide a Path to the location of your private key:
from nexmo_jwt import JWTokenGenerator
gen: JWTokenGenerator = JWTokenGenerator('your-application-id','/path/to/your/private.key')
token: bytes = gen.generate_token()
Generating a JWT with Custom Claims
It is also possible to generate a JWT with custom data:
from nexmo_jwt import JWTokenGenerator
gen: JWTokenGenerator = JWTokenGenerator('your-application-id','/path/to/your/private.key')
token: bytes = gen.generate_token(payload={"foo", "bar"})
Metadata
Release files for nexmo-jwt 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nexmo-jwt-1.0.1.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nexmo_jwt-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.3 kB
Release files / nexmo-jwt-1.0.1.tar.gz
| Download URL | nexmo-jwt-1.0.1.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a4eeb244f2b387def3e1ff2eb3f5df9f44e6aa579e483b06ffe43352bfa1bc47
|
|
BLAKE2b-256 checksum How to use checksums |
0115a7039fcaaf3f9e36e1385f01268ea1b37dce4a5b8fb1f1fc139d262a488f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1
|
Release files / nexmo_jwt-1.0.1-py3-none-any.whl
| Download URL | nexmo_jwt-1.0.1-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
88a3d3d2f76202b2ce89380f7a92548d4a028e7e3dc5d84face8be6d2117a920
|
|
BLAKE2b-256 checksum How to use checksums |
a8f037ed83eba1997f37ada5e25d60b4c5858925c70e0d03a9060bdc380b7986
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1
|