# Zoom Webhook Signature Verification Failing in Python 3 but Working in Python 2

**URL:** <https://devforum.zoom.us/t/zoom-webhook-signature-verification-failing-in-python-3-but-working-in-python-2/129186>\
**Category:** Authentication\
**Tags:** webhooks, api\
**Created:** [March 4, 2025, 12:40pm UTC](https://devforum.zoom.us/t/zoom-webhook-signature-verification-failing-in-python-3-but-working-in-python-2/129186 "2025-03-04T12:40:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kathir](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/kathir/32/49752_2.png) [@kathir](https://devforum.zoom.us/u/kathir)\
**Post date:** [March 4, 2025, 12:40pm UTC](https://devforum.zoom.us/t/zoom-webhook-signature-verification-failing-in-python-3-but-working-in-python-2/129186/1 "2025-03-04T12:40:07Z")

</div>

I am working on verifying Zoom webhooks in **both Python 2 and Python 3** within a Django application. My verification logic works correctly in **Python 2** , but when running the same code in **Python 3** , the generated hash does not match `X-ZM-SIGNATURE` from Zoom’s webhook headers.

### **Observed Behavior**

- ✅ **Python 2:** The computed HMAC SHA256 signature matches the one sent in the Zoom header (`X-ZM-SIGNATURE`).
- ❌ **Python 3:** The computed signature is **different** from the one Zoom sends, causing verification to fail.

**Code Snippet for Signature Verification**

```auto
def generate_zoom_webhook_signature(zoom_webhook_secret, request_body, event_ts):
    message = "v0:{}:{}".format(event_ts, request_body)
    return "v0={}".format(create_hmac(zoom_webhook_secret, message, hashlib.sha256))

def create_hmac(key, message, algorithm=hashlib.sha512, digest="hex"):
    encoded_data = hmac.new(
        six.ensure_binary(key, encoding="utf-8"), six.ensure_binary(message, encoding="utf-8"), algorithm
    )
    if digest == "hex":
        return encoded_data.hexdigest()
    if digest == "byte":
        return encoded_data.digest()
    return encoded_data

```
