Skip to content
Jonas Nguyen, home

writing / lessons · part 1· · 1 min read

Tokens expire quietly

A connected account does not break when you connect it. It breaks 30 or 60 days later, silently. How Clienzo learned to refresh tokens before they die.

Collage illustration: “Day 60, it stops”

Connecting an account is the part everyone tests. You sign in, you post, it works, you ship. The failure comes later — 30 or 60 days later — when nobody is watching.

How I found it

Threads gives an app a long-lived token that lasts 60 days. While planning something unrelated, I noticed nothing in Clienzo ever refreshed it. The first customers had connected Threads in early September, which meant their connections would stop working in early November. No error, no warning — scheduled posts would simply start failing.

Later, approving Pinterest, I found the same thing there with 30-day tokens. Those connections were already dead.

The fix

A daily job now goes through every connection:

  • if a token has 30 days or less left and is at least a day old, it is refreshed;
  • if the network says the token is no longer valid, the connection is marked expired and the owner gets a notification to reconnect;
  • any other error is left alone and tried again the next day, so a network having a bad day cannot disconnect anyone.

Each network gets its own small refresher, so adding one is a few lines, not a new job. Tumblr’s tokens, which last well under an hour, are refreshed just before publishing instead, with a lock so two posts going out at once do not both try to refresh the same token.

The lesson

Every integration has a clock on it. When I add a network now, “how long does the token last, and what refreshes it” is a question I answer on day one, not day 59.

Next in this series: the four days no email left Clienzo, and how I found out.