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
GET /api/v1/integrations/accounts/{accountId}reportsneeds_reconnectwith reasontoken_expiredwhen a X token can no longer be used;POST /api/v1/integrations/accounts/{accountId}/reconnectkeeps the account ID.
Related errors
- A provider 401 becomes an
authprovider error and a 403 apermissionerror; 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.