Skip to content

OAuth apps for self-hosting

Some features let a workspace member connect an external account with OAuth:

  • Ad platforms (Meta, Google Ads, TikTok): import campaign structure and daily spend, and send server-side conversions back. Members connect them in the analytics settings, Ad accounts tab. See Ad accounts.
  • Google Calendar: read the busy time of a host so booked slots never overlap their other events, and write every booking into the host’s Google Calendar as an event. Members click Connect Google Calendar on a booking calendar. See Calendars.

The Google Sheets form connection needs no OAuth app: each workspace uses its own Google service account key. See Form connections.

The OAuth apps those flows run through (the “client” registered on each platform) belong to whoever operates the installation:

  • Cloud — the operator has created the apps and configured them on every installation it runs. Workspace members only click Connect; you do not need this page.
  • Self-hosted — you create your own apps, once per installation (or one app shared by several of your installations), and you are the party the platforms review and verify.

This page is for self-hosters and operators.

Platform app Unlocks Secrets on the core worker Redirect URI to register
Meta Spend import, Conversions API META_APP_ID, META_APP_SECRET https://<your dashboard host>/oauth/ads/callback
Google Ads Spend import, click conversions GOOGLE_ADS_CLIENT_ID, GOOGLE_ADS_CLIENT_SECRET, GOOGLE_ADS_DEVELOPER_TOKEN, optional GOOGLE_ADS_LOGIN_CUSTOMER_ID https://<your dashboard host>/oauth/ads/callback
TikTok Spend import, Events API TIKTOK_APP_ID, TIKTOK_APP_SECRET https://<your dashboard host>/oauth/ads/callback
Google Calendar Booking calendars GOOGLE_OAUTH_CLIENT_ID, GOOGLE_OAUTH_CLIENT_SECRET https://<your dashboard host>/oauth/google/callback
  • Where the secrets go. All of them go on the core worker. Set them with Wrangler from the apps/core folder of your installation, or in the Cloudflare dashboard (the core Worker › Settings › Variables and secrets). Values that are not secret (META_APP_ID, GOOGLE_ADS_CLIENT_ID, TIKTOK_APP_ID, GOOGLE_OAUTH_CLIENT_ID) may also be plain variables in the vars block of the core worker configuration.

    Terminal window
    cd apps/core
    wrangler secret put META_APP_SECRET # repeat for each secret
  • Optional, one at a time. A platform without credentials simply shows as unavailable: the ad account card says Not configured on this installation., and the Google calendar sync answers Google connections are not available on this installation. Nothing else breaks. You can configure platforms one by one.

  • Development. With ENVIRONMENT=dev every provider is replaced by a deterministic fake: no apps, no credentials, no network. The connect buttons complete instantly and the dashboard says Development mode: connections use a simulated provider.

  • Redirect URIs must match exactly (scheme, host and path). The host is the public origin of your dashboard (APP_ORIGIN). The ads callback can be overridden with ADS_OAUTH_REDIRECT_URI (for example https://app.example.com/oauth/ads/callback); the Google one is fixed at /oauth/google/callback.

  • Same origin. The OAuth callback must come back to the same origin that started the flow, because the pending connection is kept in the member’s browser session. If one app serves several installations, register one redirect URI per installation origin on that app.

  • Cloud installations and Google. On installations linked to the managed offering (LICENSE_KEY set), Google Calendar connections are brokered by the control plane and no Google app is needed. An own app, when configured, always takes precedence.

  • Ad platform tokens stay server-side in your installation; the browser never sees them. They are refreshed before they expire.
  • Google Calendar grants are encrypted with the installation key (AUTH_ENCRYPTION_KEY) before being stored in the installation database.
  • Conversions sent to ad platforms carry personal identifiers only as SHA-256 hashes; plaintext email or phone is never sent. See Outbound conversions.
  • Disconnecting an account deletes the stored grant. Platforms also list the app in the user’s account permissions, where access can be revoked; a revoked grant shows the connection as Reconnect needed (ads) or disconnected (Google).

Every platform lets you test your app before review, but only with your own accounts or test users. Plan the reviews early:

Platform Before review Review Typical duration
Meta Development mode: only people with a role on the app Advanced Access for ads_read, ads_management, business_management, plus business verification A few days to about 2 weeks
Google Ads Consent screen in Testing: up to 100 test users. Developer token at Test account level: only Google Ads test accounts App verification (sensitive adwords scope) and developer token Basic access Several days to a few weeks (verification); a few business days (token)
TikTok Sandbox mode: sandbox ad accounts only Manual app review A few business days
Google Calendar Consent screen in Testing: up to 100 test users, “unverified app” warning App verification (calendar.readonly and calendar.events are sensitive scopes) Several days to a few weeks

Requested scopes: ads_read, ads_management, business_management.

  1. Make sure you have a Facebook account and a Business Portfolio. App review later requires business verification of that portfolio.

  2. Go to developers.facebook.com › My Apps › Create app. Pick the Business app type and attach your business portfolio.

  3. On the app dashboard, add the product Facebook Login for Business. Under its Settings, add to Valid OAuth Redirect URIs:

    https://<your dashboard host>/oauth/ads/callback
  4. Add the product Marketing API.

  5. In App settings › Basic, note the App ID and the App secret. Fill in the privacy policy URL, the data deletion instructions URL, the app icon and the category: all are required before the app can go live.

  1. Set the secrets on the core worker:

    Terminal window
    cd apps/core
    wrangler secret put META_APP_ID
    wrangler secret put META_APP_SECRET
  2. Redeploy, or save the secrets in the Cloudflare dashboard. The Meta card on the Ad accounts tab becomes available immediately.

  1. While the app is in Development mode, people with a role on the app (App roles › Roles: admins, developers, testers) can complete the OAuth flow against the ad accounts they can access. Connect your own ad account end to end: spend sync, reports and outbound conversions.

  2. To test conversions without affecting ad delivery, open the Conversions dialog of the connection (Ad accounts tab) and set a Test event code (optional): events then appear in Events Manager › Test events. Clear it when you are done.

  3. To let any Meta user connect, switch the app to Live and request Advanced Access for ads_read, ads_management and business_management (App review › Permissions and features). Meta asks for completed business verification, a screen recording of the OAuth flow showing why each permission is needed (connect an ad account, spend appears in reports, a conversion is sent), and working privacy policy and data deletion URLs.

Operational notes:

  • User tokens are exchanged for long-lived tokens (about 60 days). When one expires, the connection shows Reconnect needed and the member reconnects; nothing is lost.
  • Conversions go to the dataset (pixel) set on each connection with the Conversions button of the Ad accounts tab (or PATCH /ads/connections/{id}); until it is set, the row warns that server-side conversions cannot be sent. See Server-side conversions.
  • Spend is read per campaign, ad set and ad; deleted entities are zeroed on reconciliation.
  • Platform rate limits are handled with backoff by the outbound queue; failed jobs can be sent again from the outbound conversions log.
Variable Secret Required for Notes
META_APP_ID no Meta App ID from App settings › Basic
META_APP_SECRET yes Meta App secret
GOOGLE_ADS_CLIENT_ID no Google Ads OAuth client id
GOOGLE_ADS_CLIENT_SECRET yes Google Ads OAuth client secret
GOOGLE_ADS_DEVELOPER_TOKEN yes Google Ads Developer token of the manager account
GOOGLE_ADS_LOGIN_CUSTOMER_ID no Google Ads, optional Manager account id, digits
TIKTOK_APP_ID no TikTok App ID
TIKTOK_APP_SECRET yes TikTok App secret
ADS_OAUTH_REDIRECT_URI no Optional Overrides the ads callback (default <APP_ORIGIN>/oauth/ads/callback)
GOOGLE_OAUTH_CLIENT_ID no Google Calendar OAuth client id
GOOGLE_OAUTH_CLIENT_SECRET yes Google Calendar OAuth client secret
APP_ORIGIN no All Public origin of the dashboard, used to build the redirect URIs
AUTH_ENCRYPTION_KEY yes Google Calendar grants and other stored secrets Installation key (base64, 32 bytes) that encrypts stored grants and other secrets at rest
Section titled “Related credentials that are not OAuth apps”
Credential Feature Where it is documented
CF_ZONE_ID, CF_API_TOKEN (with SSL and Certificates: Edit), TRACKING_CNAME_TARGET Custom tracking domains of the CNAME kind CNAME domains
CLOUDFLARE_DNS_API_TOKEN Automatic DNS records for sending and site domains Optional tokens
SYSTEM_EMAIL binding and SYSTEM_EMAIL_FROM Transactional system email of a self-hosted installation Configuration

The organic search statistics integration (the Integrations tab of the analytics settings) has no self-hosted app: it is available only in development (fake data) or through the managed offering.

  • Setting the secrets needs access to the Cloudflare account that runs the installation (or the Wrangler CLI logged in to it).
  • Connecting ad accounts in the dashboard needs analytics:configure. Connecting a Google calendar needs booking:write; managing form connections needs forms:connections_manage.
  • Platform-side limits (test users, sandbox accounts, developer token levels) apply until each review is approved.
Symptom Cause Fix
The card says Not configured on this installation. The platform’s variables are missing on the core worker Set them and redeploy. For Google Ads, all of client id, client secret and developer token are needed.
The platform shows redirect_uri_mismatch (or a similar error) The registered redirect URI differs from the one the installation sends Register exactly https://<your dashboard host>/oauth/ads/callback (or /oauth/google/callback); check APP_ORIGIN and ADS_OAUTH_REDIRECT_URI.
The callback lands but the connection is not created The flow started on another origin (for example a workers.dev URL) than the callback Start the connection from the same host you registered.
Only some people can connect The app is still in development, testing or sandbox mode Add them as testers, or complete the platform review.
Google Ads answers DEVELOPER_TOKEN_NOT_APPROVED The developer token is at Test account level Apply for Basic access.
Google warns “unverified app” The consent screen is not verified Submit the app for verification, or keep using listed test users.
A connection shows Reconnect needed The token expired or was revoked on the platform Click Reconnect.