twilio.jwt package

Submodules

twilio.jwt.compat module

twilio.jwt.compat.compare_digest(a, b)[source]

PyJWT expects hmac.compare_digest to exist for all Python 3.x, however it was added in Python > 3.3 It has a fallback for Python 2.x but not for Pythons between 2.x and 3.3 Copied from: https://github.com/python/cpython/commit/6cea65555caf2716b4633827715004ab0291a282#diff-c49659257ec1b129707ce47a98adc96eL16

Returns the equivalent of ‘a == b’, but avoids content based short circuiting to reduce the vulnerability to timing attacks.

Module contents

class twilio.jwt.Jwt(secret_key, issuer, subject=None, algorithm='HS256', nbf=<object object>, ttl=3600, valid_until=None)[source]

Bases: object

Base class for building a Json Web Token

GENERATE = <object object>
algorithm = None
classmethod from_jwt(jwt, key='')[source]

Decode a JWT string into a Jwt object :param str jwt: JWT string :param Optional[str] key: key used to verify JWT signature, if not provided then validation

is skipped.

:raises JwtDecodeError if decoding JWT fails for any reason. :return: A DecodedJwt object containing the jwt information.

headers
issuer = None
nbf = None
payload
secret_key = None
subject = None
to_jwt(algorithm=None, ttl=None)[source]

Encode this JWT object into a JWT string :param str algorithm: override the algorithm used to encode the JWT :param int ttl: override the ttl configured in the constructor :rtype: str The JWT string

ttl = None
valid_until = None
exception twilio.jwt.JwtDecodeError[source]

Bases: Exception