yikart/AiToEarn · error · AppException

ChannelAuthAccountAccessRevoked

ChannelAuthAccountAccessRevoked

Error message

ChannelAuthAccountAccessRevoked

What it means

Facebook page lookup failed during account access refresh: the list of pages accessible by the root access token does not contain a page matching the stored platformUid. This means the app/token no longer has access to that specific Facebook Page, so the channel is treated as revoked.

Source

Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/facebook/facebook-auth.provider.ts:104

          tasks: page.tasks,
          category: page.category,
          categoryList: page.category_list,
          fansCount: page.followers_count ?? page.fan_count,
          fanCount: page.fan_count,
          followersCount: page.followers_count,
        },
      })
    }

    return accounts
  }

  async refreshAccountAccess(input: RefreshAccountAccessInput): Promise<PlatformSelectableAccount> {
    const pages = await this.facebookService.listPages(input.rootAccessToken)
    const page = pages.find(p => p.id === input.platformUid)

    if (!page) {
      throw new AppException(ResponseCode.ChannelAuthAccountAccessRevoked)
    }

    return {
      platform: AccountType.Facebook,
      platformUid: page.id,
      displayName: page.name,
      avatarUrl: page.picture?.data?.url,
      fansCount: page.followers_count ?? page.fan_count,
      credential: {
        accessToken: page.access_token,
        refreshToken: input.rootRefreshToken,
      },
      profile: {
        tasks: page.tasks,
        category: page.category,
        categoryList: page.category_list,
        fansCount: page.followers_count ?? page.fan_count,
        fanCount: page.fan_count,

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Re-authenticate the Facebook channel so a fresh token with Page access is obtained
  2. Verify the user still has a role on the target Page and that the app is still installed on it
  3. Check that input.platformUid matches the page id stored at auth time (no id remap/merge)
  4. Confirm the token was requested with pages_show_list / pages_manage_metadata scopes
Defensive patterns

Strategy: try-catch

Validate before calling

// before calling refreshAccountAccess, verify the page is still listed
const pages = await facebookService.listPages(rootAccessToken)
if (!pages.some(p => p.id === platformUid)) {
  throw new Error('Facebook page no longer accessible; re-auth required')
}

Type guard

function hasPageAccess(pages: { id: string }[], platformUid: string): boolean {
  return pages.some(p => p.id === platformUid)
}

Try / catch

try {
  await provider.refreshAccountAccess({ rootAccessToken, platformUid })
} catch (e) {
  if (e.code === 'ChannelAuthAccountAccessRevoked') {
    await markChannelRevoked(accountId)
    notifyUserToReconnect('facebook')
  } else throw e
}

Prevention

When it happens

Trigger: refreshAccountAccess is called with a rootAccessToken whose /me/accounts (listPages) response no longer includes the page with id === input.platformUid.

Common situations: Page admin removed the app or revoked the integration; the user lost admin/editor role on the Page; token was issued for a different Business/Page scope; page was deleted or merged.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/a8ffa29dd6bc09f2. Report an issue: GitHub.