JWT Generator for Nexmo
Project description
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"})
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nexmo-jwt-1.0.0.tar.gz
.
File metadata
- Download URL: nexmo-jwt-1.0.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae661d92bef2bcd6509b38fcbac34031a57b5465893dcd2d6dc3e99d577f5761 |
|
MD5 | af77a38105b8ac2b784f47ddfc3f852e |
|
BLAKE2b-256 | 815cb3fd1d66001e2c427f15088ab865193f17c6c6b27454e94435ddc38083db |
File details
Details for the file nexmo_jwt-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: nexmo_jwt-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 765dfbcda569ab906cb75422e96c4d0c11129e00e19a8bd8532d4abb1309ffcd |
|
MD5 | 059540501e655c1f6de5e0e71aeb924c |
|
BLAKE2b-256 | 0848a527c3d50168036156a7a2c4cc48f0ad75a246fd03bf506dd2dd4a9e9b0d |