def METHOD_NAME(cls, payload: dict, secret, lifetime):
    """
    Encode `payload` as a JWT.
    :param payload: payload to encode
    :param secret: secret used for encoding
    :param lifetime: how long the token should be valid for
    :return: the JWT string
    """
    payload = copy.deepcopy(payload)
    payload["exp"] = datetime.datetime.utcnow() + lifetime
    jwt_str = jwt.encode(payload, secret, algorithm="HS256")
    return jwt_str