Module auth/storage/token-refresh

Token Refresh Management Module

Provides automatic access token refresh functionality for the OAuth authentication system, ensuring continuous API access without requiring user re-authentication.

Features:

  • Proactive token refresh scheduling before expiration
  • Automatic token refresh with error handling
  • Configurable refresh safety margin for reliable token renewal
  • Circular dependency resolution through dependency injection
  • Graceful handling of refresh failures
  • Automatic timer management with cleanup
  • Comprehensive logging of refresh activities
  • Integration with Spotify API for token refresh operations

This module works in concert with the token operations and token state modules, providing time-based automatic refresh of access tokens using refresh tokens, which is essential for maintaining long-lived authentication sessions.

Functions

initTokenRefresh
scheduleTokenRefresh
refreshAccessToken