OAuth integrations break in a specific, quiet way. They work on day one, work on day two, and sometime in the following week the data stops arriving. No error. No alert. The integration is still listed as connected — it just hasn't synced in a while.
Orma (formerly xeve) had this problem for weeks before it surfaced as a bug report, from the developer to themselves, on 23 August 2026:
when i click disconnect in settings for spotify its not disconnecting , why
The question was about disconnect. The investigation found something larger.
The disconnect bug
Orma connects to Spotify, GitHub, and Whoop via OAuth. Each connector stores an access token and a refresh token when you authorise it, and the integrations page has a Disconnect button for each one.
The Disconnect button was not working. Clicking it had no visible effect; Spotify stayed listed as connected.
The fix was an indexing bug. The disconnect handler mapped the button to an integration by its position in a hardcoded list of two. When the UI grew to show three integrations, clicks on the third button had no corresponding handler — they disappeared silently. Fixed in PR #140: Make connecting and disconnecting an integration actually work.
That would have been the end of the investigation, except it wasn't.
What the tokens had never done
While looking at the disconnect code, the question came up: what happens when the access token expires?
An OAuth access token is short-lived by design — anywhere from a few hours to a few days depending on the provider. Alongside it comes a refresh token, which is long-lived and can be exchanged for a new access token at any time. The standard lifecycle is:
- The user authorises. You receive both tokens and store them.
- Before the access token expires, you exchange the refresh token for a new access token.
- Syncing continues indefinitely.
Orma's integration system was storing both tokens correctly on authorisation. It was using the refresh token to get a new access token: never, not once. The commit that added the fix carries the clearest possible description: Refresh connector tokens, which nothing has ever done.
This is an easy thing to miss when building quickly. The OAuth flow you test first is the happy path: the user signs in, the token arrives, the first sync works. Testing expiry requires either waiting several hours or manually winding the clock forward, and that step is easy to leave out. The result was that anyone who connected Spotify during the launch period would have seen their listening history stop appearing sometime in the following week, with no explanation from the app.
Three changes to make it right
Fixing token refresh properly required three changes rather than one, each addressing a different gap in the original implementation.
Record the expiry on connect. When you save a new access token, save when it expires at the same time. Orma was not storing the expiry time, which meant the refresh logic had no basis for deciding when to act. This was added in the same pass as the main fix: Store an expiry the refresh can read, on connect. Without this field, the only option would be to guess — and guessing either too early (unnecessary API calls) or too late (already expired) is both wrong in different ways.
Refresh before each sync. Each time a connector runs — Spotify on its schedule, GitHub on demand — check whether the access token is within a short window of expiring, and if so, exchange the refresh token for a new one before making any API calls. This turns a silent failure into a transparent handoff. If the exchange itself fails, the sync still fails cleanly; what it no longer does is attempt an API call with a token it already knows is stale.
Keep the refreshed token when the sync itself fails. This was PR #137, and it addressed an edge case in the first fix: if the token refresh succeeded but the subsequent sync failed — a network error, a provider outage — the new access token was being discarded along with the failed sync result. The connector would then try to use the old token on its next run, which had already been superseded by the exchange, and the exchange would fail again. The fix was to write the refreshed token to storage before attempting the sync, not after: the new token is durable even when the sync is not.
What it means in practice
The pattern that caused the problem is straightforward. A task that says "store the tokens" gets done and committed. The follow-on task "refresh the tokens periodically" goes into a backlog and never surfaces, because the integration appears to work correctly through all early testing. The token expires in production, and the data disappears.
The two things Orma's initial build skipped are both easy to add at the moment you first implement the OAuth callback, and much harder to retrofit:
- Store the access token expiry at the same time you store the token itself.
- Write a test that fast-forwards past the expiry and verifies the next sync still succeeds.
After these fixes, the integrations page on Orma reflects what the connectors are actually doing. Connected means actively syncing; Disconnect removes the tokens and stops it.

The Coding dashboard showing coding time by project, language and editor.
