def METHOD_NAME(*args, **kwargs):
    """
    Validate webhook payload.
    Checks weather clientState matches MICROSOFT_SUBSCRIPTION_SECRET
    which we use to create subscriptions. Also checks @odata.type as we
    have two separate endpoints, one for calendar changes and one for
    event changes.
    """
    try:
        request.json
    except BadRequest:
        return ("Malformed JSON payload", 400)
    change_notifications: List[MsGraphChangeNotification] = cast(
        MsGraphChangeNotificationCollection, request.json
    )["value"]
    if any(
        notification["clientState"] != config["MICROSOFT_SUBSCRIPTION_SECRET"]
        for notification in change_notifications
    ):
        return (
            "'clientState' did not match one provided when creating subscription",
            400,
        )
    if any(
        notification["resourceData"]["@odata.type"] != type
        for notification in change_notifications
        if notification.get("changeType")
    ):
        return f"Expected '@odata.type' to be '{type}'", 400
    return view_function(*args, **kwargs)