def encode(payload, key, algorithm='HS256'):
    segments = []
    header = {"typ": "JWT", "alg": algorithm}
    segments.append(base64url_encode(binary(json.dumps(header))))
    segments.append(base64url_encode(binary(json.dumps(payload))))
    sign_input = '.'.join(segments)
    try:
        signature = signing_methods[algorithm](binary(sign_input), binary(key))
    except __HOLE__:
        raise NotImplementedError("Algorithm not supported")
    segments.append(base64url_encode(signature))
    return '.'.join(segments)
dataset/ETHPy150Open awslabs/lambda-apigateway-twilio-tutorial/twilio/jwt/__init__.py/encode