Detect and log invalid feed token attempts
Invalid token attempts — wrong hash, revoked token, or unknown prefix — signal token sharing, credential stuffing, or misconfigured apps. This recipe logs each attempt with the token prefix (safe to log; not recoverable to the full token) and show ID, giving you the data to build rate-limiting or alerting on repeated failures from the same show.
Code
<?php
add_action( 'benecaster_token_invalid', function ( string $token_prefix, int $show_id ) {
// Log to your security/observability platform.
error_log( sprintf( 'Invalid Benecaster token attempt: prefix=%s show=%d ip=%s',
$token_prefix,
$show_id,
$_SERVER['REMOTE_ADDR'] ?? 'unknown'
) );
// Or push to a rate-limiter keyed on IP + show.
}, 10, 2 );