ØSTEN AI

OAuth & Integrations

  • Backend callback route: GET/POST /api/google-ads/auth/callback handled by googleAdsController.handleAuthCallback
  • Frontend success page: frontend/app/oauth/google-ads/success/page.tsx
  • Available accounts: GET /api/google-ads/auth/available-accounts?accessToken=...
  • Create account: POST /api/google-ads/accounts/create

Redirect URIs (production)

  • If using custom domains:
    • Google Ads: https://app.ostenai.com/api/google-ads/callback (ensure this maps to backend .../auth/callback or adjust accordingly)
    • Meta Ads: https://app.ostenai.com/api/meta-ads/callback
    • TikTok Ads: https://app.ostenai.com/api/tiktok-ads/callback
  • Backend Cloud Run example env:
    • GOOGLE_OAUTH_REDIRECT_URI=https://<cloudrun-host>/api/google-ads/auth/callback

Known Requirements / Gotchas

  • Google Ads API requires:
    • Authorization: Bearer <OAUTH2_ACCESS_TOKEN>
    • Content-Type: application/json
  • API access belongs to the Google Cloud project that owns the OAuth client (GOOGLE_OAUTH_CLIENT_ID). Google sunset developer tokens on 2026-09-09; the client sends developer-token only when GOOGLE_ADS_DEVELOPER_TOKEN is set, and the API ignores it. A future major version will reject the header, so remove the token before that upgrade. See https://developers.google.com/google-ads/api/docs/api-policy/developer-token
  • customers:listAccessibleCustomers may return 501 if the Cloud project's API access level does not allow the operation or the account hierarchy is not a Manager account (MCC).
  • The service handles 501 by returning guidance/demo entries; upgrade access or use test manager + test accounts.

Meta Ads & TikTok Ads

  • Similar available-accounts and connect flows under /api/meta-ads/* and /api/tiktok-ads/*
  • Frontend success pages under frontend/app/oauth/meta-ads/success/page.tsx and frontend/app/oauth/tiktok-ads/success/page.tsx
  • Meta upgrades the short-lived code straight to a long-lived (~60 day) token, and that token cannot be refreshed server-side — after it expires the user has to re-authorize. The sync records marketing_accounts.sync_status = 'needs_reconnect' when it hits Graph code 190, and GET /api/meta-ads/connection-status reports both that and tokens expiring within 7 days. The internal docs/meta-ads.md covers the connector in full.

Google Analytics 4 (GA4)

  • GA4 uses a frontend callback page to complete the OAuth flow and let the user pick a property.
  • Frontend callback route: frontend/app/(dashboard)/dashboard/google-analytics/callback/page.tsx

Redirect URI (production)

  • Google Analytics (GA4): https://app.ostenai.com/dashboard/google-analytics/callback
    • Set this exact URI in the Google Cloud Console OAuth client.
    • Set backend env var GOOGLE_ANALYTICS_REDIRECT_URI to the same URI so backend-generated links remain consistent.

Notes

  • GA scripts must only load on public pages (landing, marketing, login, signup, data deletion) — do not load on OAuth success pages or any dashboard pages.
  • After callback, the frontend exchanges the authorization code with the backend to list properties and save the selected property.

On this page