Nango shares OAuth lessons from 1,000+ APIs after a token-loss bug

Nango shares OAuth lessons from 1,000+ APIs after a token-loss bug

Nango is an open-source project that lets web applications and agents integrate with third-party APIs. Customers embed it in their products, their users connect third-party accounts, and Nango keeps those connections working. In a blog post on operating auth for 1,000+ APIs, the company starts with its own failure.

In May 2025 Nango merged a PR with a critical bug: an if condition that never fired, so refreshed credentials were not saved to the database. The team caught it and reverted it in just under two hours. In that time, scheduled jobs had refreshed and discarded access and refresh tokens for hundreds of connections. For most APIs this was recoverable, because the old refresh token still worked and the next scheduled refresh repaired the connection. But many providers, including Airtable and Atlassian, invalidate the old refresh token the moment a replacement is issued, and Salesforce and Slack can do the same when rotation is enabled for the OAuth app. For those connections there was no way to get the tokens back, and Nango's customers had to ask every affected user to go through the consent screen again. Since then Nango has grown from about 400 APIs to 1,000+.

Lesson 1: token rotation makes ordinary bugs irreversible. Rotation is a security win, but a bug in the rotation path can permanently destroy a connection. Nango now treats refresh tokens "like money, not cache": the new token is persisted before anything else can fail, the persistence path has its own regression tests, and platform-level refresh anomalies page the on-call team. Providers enforce rotation differently. With Airtable, a refresh with a stale token or the wrong client credentials can return a 400 or 401, but it also revokes the user's entire authorization for the app, and the only way back is for the user to reconnect. Sending the same refresh request twice can also trigger revocation; Airtable documents a short grace period for duplicates, but retrying the stale token after that period revokes the authorization. Airtable also invalidates the old access token the instant a refresh succeeds, so a long-running job on an old token can fail mid-run. Xero is more forgiving: if a refresh fails or the response never arrives, you can retry with the previous refresh token for up to 30 minutes. Such issues pushed Nango to serialize refreshes per connection behind a distributed lock. Even refreshing early can be wrong. Exact Online access tokens last 10 minutes, and its token endpoint rejects any refresh made more than 30 seconds before expiry. Nango's "refresh 15 minutes early" rule meant every refresh was rejected, so it added per-provider expiration buffers.

Lesson 2: you cannot reliably know when access tokens expire. RFC 6749 makes expires_in optional for access tokens, which Nango calls a recurring source of silent breakage. Zendesk rolled out expiring access tokens for OAuth clients, including existing ones, and includes expires_in in the token response only if you request it. Without it the token still expires under the default policy, but the response does not say when. Nango found out only after the rotating refresh token lapsed and connections started dying. Salesforce's token response has no expiry at all; the documented check is a separate introspection endpoint, which Nango calls before deciding whether to refresh. In June 2024 that endpoint began intermittently returning unsupported_token_type for some tokens. Nango refreshed anyway, and the replacement token could be introspected normally, though Nango never learned why the original failed. Refresh token lifetimes vary too: NetSuite's OAuth refresh tokens expire after 7 days and need full re-consent (which is why many teams use its token-based authentication instead), while Google's live indefinitely except under documented conditions: the app in Testing status, six months without use, or a user exceeding 100 live refresh tokens for the client. Nango now refreshes stale credentials on a cron so tokens are exercised before inactivity kills them.

Auth failures also do not always look like failures. Zoho CRM's token endpoint returns HTTP 200 with the error in the body. Workday and Dayforce return no error when a permission policy is missing; the API just returns empty data. One SOAP-based API returns HTTP 200 for everything, including wrong passwords. LastPass does the same with plain text in the body, and Nango's credential check literally searches the response for the string "Authorization Error". Nango therefore builds per-provider heuristics: at the time of the analysis, 276 of the roughly 935 providers in its registry declared an authenticated endpoint Nango can call to check that credentials still work.

Lesson 3: providers make breaking changes to their auth. 16% of commits to Nango's provider config are fixes, and there is no reliable feed for provider auth changes; Nango often learns of them from a failed flow or a customer report. Figma announced by email that credentials had to move from the request body to a Basic Authorization header and that the OAuth host was changing. Shopify changed how offline tokens are issued, so apps began receiving expiring tokens where they previously did not; Nango shipped a config change to preserve the old behavior.

Lesson 4: sometimes you build around the provider. Supporting a new API assumes you can get test credentials and find accurate docs, and at Nango's scale both often fail. Salesforce Data Cloud is separately provisioned and absent from Nango's test orgs, and its auth needs two chained token exchanges against different hosts, so Nango built a mock server from the documented responses. LastPass's API is not really REST (nearly every operation hits the same URL, with the action in the request body), so Nango added support for APIs with only a base URL. A community member found the fix for a recurring Asana OAuth error (client_id is missing or invalid) in Asana's support forum and added it to Nango's docs, since Asana's own docs did not cover it. Read.ai's documented authorization URL pointed at an internal developer-testing page; the real endpoint came from its OpenID discovery endpoint.

The post closes with ten requests for API providers: always return expires_in, in seconds; if you rotate refresh tokens, consider a short, bounded grace period for the previous token, like Xero's 30 minutes, which absorbs duplicate refreshes at the cost of weaker replay detection in that window; return more specific errors than invalid_grant; treat auth changes as breaking changes (version them, announce them, do not apply them retroactively); document revocation triggers such as password resets, per-user token caps and inactivity windows; offer a way to test without a sales call; keep auth docs public and accurate; make 200 mean success; prefer conventional behavior where the spec leaves room for interpretation; and, if REST is the modern API, make it the source of truth rather than leaving functionality only in SOAP or WSDL files. Nango's provider registry is public in a single YAML file.

Key facts

  • In May 2025 a Nango PR stopped refreshed credentials being saved; it was reverted in just under two hours, but scheduled jobs had already refreshed and discarded tokens for hundreds of connections.
  • Providers that rotate refresh tokens, such as Airtable and Atlassian (and Salesforce and Slack when rotation is enabled), made the loss unrecoverable: affected users had to go through the consent screen again.
  • Nango now persists the new refresh token before anything else can fail, serializes refreshes per connection behind a distributed lock, and refreshes stale credentials on a cron.
  • Provider behavior is inconsistent: Exact Online rejects refreshes made more than 30 seconds before a 10-minute expiry, Zendesk returns expires_in only on request, Zoho CRM returns HTTP 200 with errors in the body.
  • Only 276 of roughly 935 providers in Nango's registry declare an endpoint that can verify credentials, and 16% of commits to its provider config are fixes.

Why it matters

OAuth is a standard, but Nango's account shows that providers are not interchangeable and that some differences are undocumented and only surface in production. The central point is that token rotation turns an ordinary bug into a permanent one: the same defect was self-healing for most APIs and destroyed connections for providers that invalidate the old refresh token as soon as a new one is issued. The post is useful as a catalogue of concrete provider behavior (Airtable, Xero, Exact Online, Zendesk, Salesforce, NetSuite, Google, Zoho CRM) drawn from running auth for 1,000+ APIs.

Who it affects

Anyone building product integrations or agents that hold users' OAuth credentials for third-party services. Nango's own customers were hit directly, since they had to ask their users to reauthorize. The ten requests at the end are aimed at API providers, who control things like expires_in, error bodies and how auth changes are announced.

How to use it

The post describes what Nango does, which integrators can compare against their own setup. Persist a rotated refresh token before anything else can fail, and give that path its own regression tests and on-call alerting. Serialize refreshes per connection behind a distributed lock. Allow per-provider expiration buffers instead of one early-refresh rule. Refresh stale credentials on a cron so inactivity does not expire them. Build per-provider credential checks, since some APIs return 200 for failures. Nango's provider registry is public in a single YAML file for anyone who wants the details.

How solid is it

This is a first-person engineering account from Nango, which sells and operates the product, so the incident and the provider behavior are as Nango reports them. The incident figures are loose: "hundreds of connections" and "just under two hours". The cause of Salesforce's intermittent unsupported_token_type errors was never learned. The post's "1,000+ APIs" figure differs from the roughly 935 providers counted in the registry at the time of the analysis, and the post does not reconcile the two. No dates are given for the Figma, Shopify or Zendesk changes.

Risks and caveats

Provider behavior described here can change, and Nango notes there is no reliable feed for auth changes; it often learns of them from a failed flow or a customer report. Its fixes also have limits: only 276 of roughly 935 providers expose an endpoint that can check whether credentials still work, so heuristics are needed elsewhere. The suggested grace period for rotated tokens comes with a stated trade-off of weaker replay detection during that window. Nothing in the post says which customers' connections were lost.

“We now treat refresh tokens like money, not cache.”

— Nango, in its blog post on operating auth for 1,000+ APIs