Skip to main content

Detect and respond to per-show token revocation so add-ons can pause outbound work before the operator reconnects

Free Intermediate Since v1.0.0

LicenseValidationCron uses a two-strike counter per show on HTTP 401 from /validate. The first 401 fires benecaster_license_unauthorized_strike( int $strike_count, string $show_uuid ) — useful for observability. A second consecutive 401 fires benecaster_license_reconnect_required( string $show_uuid ) and sets a reconnect flag. Revocation on one show has no effect on other connected shows. Use the strike action for alerting on transient auth issues; use the reconnect-required action to pause outbound work for that show until the operator reconnects.

Code

<?php
add_action( 'benecaster_license_unauthorized_strike', function ( int $strike_count, string $show_uuid ): void {
    // First strike is usually a transient header-stripping incident — log it
    // so operators can correlate against host proxy anomalies, but do not
    // change behavior yet. Strike 2 fires the reconnect_required action.
    my_addon_metric( 'benecaster.license.401_strike', [
        'count'     => $strike_count,
        'show_uuid' => $show_uuid,
    ] );
}, 10, 2 );

add_action( 'benecaster_license_reconnect_required', function ( string $show_uuid ): void {
    // Pause outbound work for this specific show — other shows are unaffected.
    // The Reconnect to Benecaster admin notice already prompts the operator.
    my_addon_pause_outbound_syncs_for_show( $show_uuid );
} );

View on GitHub →

Hooks Used

  • benecaster_license_reconnect_required
  • benecaster_license_unauthorized_strike