Design note — Google Ads OAuth door (google_ads)

Target registry item: C1a (OB-GAP-1 — the typed Google Ads card requires a tenant-owned OAuth client, which a small business cannot supply). Status: design note only — NOT built. The google_ads catalog row stays exactly as measured on 2026-10-12 (oauth_client_id, oauth_client_secret, refresh_token, customer_id required; login_customer_id, legacy developer_token optional); nothing in this note changes it until the owner answers OB-GAP-1. Connector Definition of Done (CDoD) points 1–14 are tracked in docs/reports/ONBOARDING_CONNECTORS_STATE.md.

Auth

Two custody paths, both ending in the same vault entry and the same pull adapter (GoogleAdsAdapter, services/service-marketing-connectors/direct_connectors.py):

  1. Platform OAuth door (new, this note). A platform-owned OAuth web client on Track O. The tenant clicks "Connect Google Ads" on the card, is sent to Google's consent screen under the platform client, grants the Ads scope on their own Google account, and the callback exchanges the code for a refresh token which is written to the vault by the server. The tenant never sees or types a client id, client secret or refresh token. The Google Cloud project that owns the client decides API access (Google retired developer tokens on 2026-09-09; access levels now belong to the Cloud project — fetched 2026-10-12, see Vendor references). The owner-ruling boundary (D2/D11, docs/product/SIGNAL_SHOPIFY_MASTER_v4.md §3.6a): the ad account stays merchant-owned and the grant is merchant-made; only the OAuth client is platform-owned, exactly as the Shopify install's app is.
  2. Bring-your-own-client (typed card, kept). The current fields, unchanged, for a tenant that owns a Cloud project with Ads API access.

Vault payload gains a custody marker so the two cannot be confused: oauth_custody: "platform" | "tenant". A platform-custody entry carries NO oauth_client_id / oauth_client_secret (the platform's live in Secret Manager on the operator path and are read by env NAME at refresh time, never from a tenant payload); a tenant-custody entry carries them as today. Masking follows the schema-2 rule already in connector_credentials.py (SCHEMA2_NON_SECRET_KEYS): fail-closed, only an allow-listed set of keys is echoed.

Door mechanics mirror shopify_install.py one for one: a StateNonceStore state parameter bound to the authenticated tenant; the callback is accepted only when the nonce matches; the tenant is the session's tenant (TENANT-001), never a query parameter; the registered redirect URI is a fixed platform URL.

Vault-only resolution per (tenant, provider); no environment fallback; vault error → 503 credential_store_unavailable (fail-closed); absent entry → merchant_credentials_not_configured. account_id in a sync body is a confirmation that must match the declared customer_id, never an override (direct_connectors.py ACCOUNT BINDING).

Fields (catalog row, when built)

Platform-custody path (the typed secret fields are not shown; the card shows a "Connect Google Ads" action in their place):

key label secret required pattern help
customer_id Customer ID no yes ^\d{3}-?\d{3}-?\d{4}$ The 10-digit customer ID shown top-right in the Google Ads UI (dashes optional). NOT the AW-… conversion tag or a GT-… tag — those are browser gtag ids and cannot be converted. (unchanged)
login_customer_id Manager (MCC) customer ID no no ^\d{3}-?\d{3}-?\d{4}$ Only if access is granted through a manager account; the same 10-digit format. (unchanged)
refresh_token — (written by the callback) yes yes (server-written) — Never typed on the platform path; masked …tail on status.
oauth_custody — (server-written) no yes ^(platform\|tenant)$ Which client minted the refresh token. Never a form field.

Tenant-custody path: the row exactly as measured today. The legacy developer_token stays optional-and-ignored for the reasons recorded in the catalog comment (re-save of an old card; masking).

Scopes

https://www.googleapis.com/auth/adwords only (the one Ads API scope; its exact string was not re-fetched from this sandbox on 2026-10-12 — verify at build, CDoD point 1). Google Ads has no read-only scope, so read-only is enforced by the adapter: only googleAds:search / searchStream (GAQL) are called; no mutate service is imported or constructed, pinned by a test in the "no module imports an HTTP mutate path" style of rule 01. The Enhanced Conversions rail is a separate write path and stays dark under MEASUREMENT_WRITEBACK=false; this note does not touch it.

Data topics

Campaign / ad group / keyword performance rows by date (impressions, clicks, cost, conversions, conversion value); conversion-action metadata; accessible-customer list (used only for the binding check). All aggregate; API version resolved at call time from provider_versions (never a module literal — API compatibility repair 2026-10-01).

topic posture
campaign performance (aggregate) de-personalised remainder; no person-level field exists in the source
conversion-action metadata configuration data, not personal data
accessible customers account identifiers of the merchant's own accounts; stored only as the declared customer_id / login_customer_id

A posture test in the TestD3ProcessingPosture style (tests/connectors/test_shopify_gateway.py) pins that no mapper output field is person-level.

Mapper target

Unchanged: GoogleAdsAdapter → CanonicalRecord (record_type: campaign_performance, source_system: marketing_connector:google_ads:campaign_performance) → gateway callback → canonical ingestion → mizoki_unified_data. No new store; the door only changes how the refresh token arrives in the vault.

Failure modes → test-connection verdicts

Failure Verdict / fix
State nonce missing / mismatched on callback oauth_state_invalid (400) → "Start the connection again from the Connectors page."
Code exchange refused by Google oauth_exchange_failed → merchant-readable copy with retryable: true; nothing written.
Declared customer_id (or MCC) not among listAccessibleCustomers for the granting user account_not_granted → "Sign in as a user who has access to customer <id>, or add that user in Google Ads → Admin → Access and security." (the existing hard check, kept)
CLOUD_PROJECT_NOT_APPROVED_FOR_PRODUCTION / ACTION_NOT_PERMITTED 503 google_ads_access_not_configured (already named in direct_connectors.py) — operator item: the platform project needs Explorer or Basic access.
Refresh token revoked (user removed the grant, password reset) credentials_revoked → card shows "Reconnect"; the entry is not deleted (status keeps configured: true, healthy: false).
AW-… / GT-… typed as customer id 422 invalid_field_format with the help text (unchanged).
Vault read error 503 fail-closed.
No vault entry merchant_credentials_not_configured before any provider call.

Flag

GOOGLE_ADS_OAUTH_DOOR default OFF (source literal, ast-asserted like the Shopify flags). Flag OFF: the card renders the typed path only and the door routes answer 404 (not 401 — the assertion that only the built code satisfies, rule 01). The oauth.available readout the Shopify card already has (oauthUnavailableCopy, marketing-connectors.tsx) is reused so the UI never guesses.

Owner / operator gates

Vendor references

← All docsView source on GitHub →