def METHOD_NAME(
    payload,
    secret="test_secret",
    algorithm="HS256",
    headers=None,
    lifetime=None,
):
    """Return payload encoded to a jwt with secret and algorithm."""
    payload = copy.deepcopy(payload)
    if lifetime:
        payload["exp"] = datetime.datetime.utcnow() + lifetime
    return jwt.encode(payload, secret, algorithm=algorithm, headers=headers)