<#3831 feat(taps): Refresh OAuth access tokens sho...
# meltano-repo-activity
g
#3831 feat(taps): Refresh OAuth access tokens shortly before they expire Pull request opened by visch APIs validate the token against their own clock, so a request sent in the final moments of the token's life races clock skew and network latency and can come back as a fatal 401. Long-running syncs that cross the token lifetime fail intermittently right at the expiry mark. Add a
token_expiry_margin
(class attribute and constructor argument, default 5 minutes) and treat the token as expired that many seconds early. The margin is capped at half of the token's lifetime so short-lived tokens don't trigger a refresh on every request. Summary by Sourcery Refresh OAuth access tokens before their stated expiry to improve reliability for long-running syncs. New Features: • Add configurable early refresh for OAuth access tokens through the
token_expiry_margin
setting, defaulting to five minutes. Bug Fixes: • Prevent requests from using OAuth tokens during the final moments of their lifetime, reducing failures caused by clock skew and network latency. Enhancements: • Cap the expiry margin at half the token lifetime and clamp negative margins to ensure short-lived tokens remain usable. Tests: • Add coverage for default, custom, disabled, capped, and negative token expiry margins. meltano/sdk