Validate incoming webhooks from Zoom

To validate incoming webhooks from Zoom, add the following code snippet towards the end of your child theme’s functions.php. Please make sure you update the snippet with your App secret token.

/**
 * Snippet to validate incoming webhooks from Zoom.
 */
add_filter( 'rest_request_after_callbacks', 'automator_validate_zoom_webhook', 10, 3 );
function automator_validate_zoom_webhook( $response, $handler, $request ) {
	
	$app_secret_token = 'replace_with_your_app_secret_token'; // <<< Update this value
	$request_params = $request->get_json_params();
	if ( empty( $request_params['event'] ) ) {
		return $response;
	}
	if ( 'endpoint.url_validation' !== $request_params['event'] ) {
		return $response;
	}
	if ( empty( $request_params['payload']['plainToken'] ) ) {
		return $response;
	}
	$plain_token = $request_params['payload']['plainToken'];
	$encrypted_token = hash_hmac( 'sha256', $plain_token, $app_secret_token );
	
	$response_body = array(
		'plainToken' => $plain_token,
		'encryptedToken' => $encrypted_token
	);
	$response = new WP_REST_Response( $response_body, 200 );
	return $response;
}

To get the app secret token, find your app in the list here and then go to the “Feature” tab.