adafruit_jwt

JSON Web Token Authentication

  • Author(s): Brent Rubell

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_jwt.JWT

JSON Web Token helper for CircuitPython. Warning: JWTs are credentials, which can grant access to resources. Be careful where you paste them! :param str algo: Encryption algorithm used for claims. Can be None.

static generate(claims, private_key_data=None, algo=None, headers=None)

Generates and returns a new JSON Web Token. :param dict claims: JWT claims set :param str private_key_data: Decoded RSA private key data. :param str algo: algorithm to be used. One of None, RS256, RS384 or RS512. :param dict headers: additional headers for the claim. :rtype: str

static validate(jwt)

Validates a provided JWT. Does not support validating nested signing. Returns JOSE Header and claim set. :param str jwt: JSON Web Token. :returns: The message’s decoded JOSE header and claims. :rtype: tuple

class adafruit_jwt.STRING_TOOLS

Tools and helpers for URL-safe string encoding.

static translate(s, table)

Return a copy of the string in which each character has been mapped through the given translation table. :param string s: String to-be-character-table. :param dict table: Translation table.

static urlsafe_b64decode(payload)

Decode bytes-like object or ASCII string using the URL and filesystem-safe alphabet :param bytes payload: bytes-like object or ASCII string

static urlsafe_b64encode(payload)

Encode bytes-like object using the URL- and filesystem-safe alphabet, which substitutes - instead of + and _ instead of / in the standard Base64 alphabet, and return the encoded bytes. :param bytes payload: bytes-like object.