def decode(jwt, key='', verify=True):
    try:
        signing_input, crypto_segment = jwt.rsplit('.', 1)
        header_segment, payload_segment = signing_input.split('.', 1)
    except ValueError:
        raise DecodeError("Not enough segments")
    try:
        header_raw = base64url_decode(binary(header_segment)).decode('utf-8')
        payload_raw = base64url_decode(binary(payload_segment)).decode('utf-8')
        header = json.loads(header_raw)
        payload = json.loads(payload_raw)
        signature = base64url_decode(binary(crypto_segment))
    except (ValueError, TypeError):
        raise DecodeError("Invalid segment encoding")
    if verify:
        try:
            method = signing_methods[header['alg']]
            if not signature == method(binary(signing_input), binary(key)):
                raise DecodeError("Signature verification failed")
        except __HOLE__:
            raise DecodeError("Algorithm not supported")
    return payload
dataset/ETHPy150Open awslabs/lambda-apigateway-twilio-tutorial/twilio/jwt/__init__.py/decode