getCode(); if ($code === 401 || $code === 403) { return true; } $message = $e->getMessage(); if ($message === '') { return false; } // Substring markers — order doesn't matter, any hit is auth. // Case-insensitive because the Google client and the auth // library disagree on casing across versions. $markers = ['invalid_grant', 'scopeInsufficient', 'PERMISSION_DENIED']; foreach ($markers as $marker) { if (stripos($message, $marker) !== false) { return true; } } return false; } }