Skip to main content

Automatic token refresh

Nango automatically refreshes OAuth access tokens before they expire. You don’t need to implement any refresh logic in your application. To prevent token revocation due to inactivity (some APIs revoke unused refresh tokens), Nango refreshes each access token at least once every 24 hours.

What happens when refresh fails

A refresh can fail when:
  • The user revokes access in the external app
  • The provider revokes the refresh token
  • The provider has an outage
Enable auth webhooks to get notified when a refresh fails. Nango retries on its regular refresh cycle, and a temporary outage can resolve on the next attempt. Give those retries a chance to succeed before prompting the user to reconnect. When a connection recovers, Nango sends a follow-up webhook with "success": true so your app can detect recovery without polling. After several consecutive days of failed refreshes, Nango stops retrying.

Detect invalid credentials

Auth webhooks

Enable Auth: token refresh webhooks under Environment Settings > Webhooks. An auth webhook with operation: "refresh" and success: false tells your app which connection failed to refresh. Use connectionId to identify the connection and error to see what happened before deciding whether to prompt the user to reconnect.

Nango API

When Nango reaches its refresh retry limit, Get a connection can return HTTP 424 with invalid_credentials. The same error can appear in Nango logs.

Provider logs

In Logs, look for a Token refreshed operation. A provider that rejects an expired or revoked refresh token may return invalid_grant. The error code and description vary by provider.

Reconnect the user

  1. Monitor failures and recoveries — Enable auth webhooks so your app knows when refresh fails and when it recovers.
  2. Handle revoked credentials — If credentials remain invalid, show a reconnect prompt so the user can authorize again.
  3. Implement reauthorization — Follow Add re-authorization to let users reconnect an existing connection.
Refresh token revocation is a normal part of integrations, and providers can revoke tokens unexpectedly. Investigate if you see an unusual increase in revocations for a provider.