Keep refreshed authentication tokens synchronized with background tracking storage
Background location tracking may run outside the normal foreground request flow and read its bearer credentials from SharedPreferences. When the authenticated HTTP client refreshes an expired token, update the tracking copy of the access token—and refresh token when available—in the same successful refresh path as secure storage.
Otherwise, foreground API requests can recover from a 401 while the background tracking isolate continues using stale credentials and queues otherwise valid location points offline.
The tracking start path should also persist the current access and refresh credentials before launching tracking. Token persistence failures should not make the foreground refresh fail, but should be observable through logging or diagnostics where practical.