Skip to content

X API OAuth 2.0 token lifetimes

X OAuth 2.0 tokens: access tokens last two hours, refresh tokens come only with offline.access, and authorization codes have a 30-second limit. When PubNio refreshes.

An X OAuth 2.0 access token stays valid for two hours. X issues a refresh token only when the app asks for offline.access. The authorization code has a 30-second time limit, so exchange it at once. (Checked 2026-12-05.)

Facts

Fact Official value Source Checked
Access token Two hours X API: OAuth 2.0 Authorization Code Flow with PKCE 2026-12-05
Refresh token issued Only with offline.access X API: OAuth 2.0 Authorization Code Flow with PKCE 2026-12-05
Authorization code (seconds) 30 X API: OAuth 2.0 Authorization Code Flow with PKCE 2026-12-05

Where official docs disagree

The official pages read for this page agree on every value above.

What PubNio enforces

  • PubNio asks for offline.access and refreshes an X token 10 minutes before it expires.

Read the live value

  • A provider 401 becomes an auth provider error and a 403 a permission error; neither is retried.
  • X error codes lists the errors PubNio returns for X and how to fix each.

Limits

  • PubNio does not migrate OAuth 1.0a user tokens; X accounts connect with OAuth 2.0.

Sources

  • X API: OAuth 2.0 Authorization Code Flow with PKCE, checked 2026-12-05

    will only stay valid for two hours unless you’ve used the `offline.access` scope.
    an OAuth 2.0 refresh token will be issued.
    The auth_code has a time limit of 30 seconds
  • X API: Apps, checked 2026-12-05

    scheduled to be retired on January 31, 2027.

Type to search…

↑↓ navigate↵ selectEsc close