You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TikTok: expired access token is never refreshed ("Access token is incorrect or has been revoked" not mapped to AuthException) #1754
On a self-hosted 1.18.0 install, a TikTok connection stops working 24 hours after it is connected, and the SDK never refreshes the token, even though a valid refresh token (1 year) is stored.
When the access token expires, TikTok's Business API answers with the message Access token is incorrect or has been revoked. The TikTok error mapper does not recognise this text as an auth failure, so it is thrown as a plain TiktokAPIException instead of an AuthException. invokeWithRefresh only forces a refresh on AuthException, so the reactive refresh path is never taken and every later call keeps failing with the same error.
Evidence (1.18.0, also unchanged on main as of 1.22.0)
None of these matches Access token is incorrect or has been revoked. (note "has been revoked", not "token revoked"), and the response is not an HTTP 401, so isRevokedTokenError / the 401 shape check do not catch it either.
Observed on our install:
IntegrationTiktok row: createdAt = updatedAt = connect time, tokens.expiresAt = connect time + 24h, tokenRefreshError = null, i.e. no refresh was ever attempted.
From the next day on, the worker logs resolveTiktokCommenterIdentity: lookup failed with TiktokAPIException: Access token is incorrect or has been revoked., followed by TikTok commenter identity unresolved, withholding automation, so comment automations silently stop.
Calling tt_user/oauth2/refresh_token/ manually with the stored refresh token succeeds (code: 0), so the refresh token itself was fine.
Part of this was on our side: we were not running the schedule worker, so the daily refreshChannelTokens job never ran. We have added it now. But the reactive path should still recover on its own, since any install where the daily job fails or is late will hit the same wall until someone reconnects.
Suggested fix
Treat this TikTok message as an auth failure, e.g. add "has been revoked" / "access token is incorrect" to AUTH_FAILED_PATTERNS (or map TikTok's error code for invalid/expired tokens), so the error becomes an AuthException and invokeWithRefresh refreshes and retries. It would also help if the commenter identity lookup went through the same refresh wrapper.
Activity
fix(tiktok): refresh expired access tokens on demand and share one re…