Marketing skills for Claude Code and AI agents. CRO, copywriting, SEO, analytics, and growth engineering.
JavaScript agent-skillsai-agentsai-seoclaudeclaude-codeclaude-code-pluginclaude-skillscodexcontent-marketingconversion-rate-optimizationcopywritingcursoremail-marketinggenerative-engine-optimizationgrowth-marketingmarketingmarketing-automationsaas-marketingseoskill-md
fix(google-ads): allow Cloud project access without developer token
Rudy Celekli0380a34d5277
diff --git a/tests/clis/google-ads-project-auth.test.cjs b/tests/clis/google-ads-project-auth.test.cjsnew file mode 100644index 0000000..efe9c0b--- /dev/null+++ b/tests/clis/google-ads-project-auth.test.cjs@@ -0,0 +1,46 @@+const { test } = require('node:test')+const assert = require('node:assert/strict')+const { spawnSync } = require('node:child_process')+const path = require('node:path')+const cli = path.resolve(__dirname, '../../tools/clis/google-ads.js')+function run(args, env = {}, oracle = '') {+ const code = `global.fetch = async (url, options) => {+ const assert = require('node:assert/strict');+ assert.equal(url, 'https://googleads.googleapis.com/v24/customers/5556667777/googleAds:searchStream');+ assert.equal(options.method, 'POST');+ assert.equal(options.headers.Authorization, 'Bearer test-token');+ ${oracle}+ return new Response(JSON.stringify([{results:[{customer:{id:'5556667777'}}]}]), {status:200});+ }; process.argv = ['node', ${JSON.stringify(cli)}, ...${JSON.stringify(args)}]; require(${JSON.stringify(cli)});`+ const childEnv = {...process.env, GOOGLE_ADS_TOKEN:'test-token', GOOGLE_ADS_CUSTOMER_ID:'5556667777', GOOGLE_ADS_DEVELOPER_TOKEN:undefined, GOOGLE_ADS_LOGIN_CUSTOMER_ID:undefined, ...env}+ for (const [key, value] of Object.entries(childEnv)) if (value === undefined) delete childEnv[key]+ return spawnSync(process.execPath, ['-e', code], {encoding:'utf8', env:childEnv, timeout:10000})+}+function result(r) { assert.equal(r.status, 0, r.stderr); return JSON.parse(r.stdout) }+test('Cloud-project OAuth access does not require a sunset developer token', () => {+ const p = result(run(['account', 'info'], {}, "assert.equal(Object.hasOwn(options.headers, 'developer-token'), false); assert.equal(JSON.parse(options.body).query, 'SELECT customer.id, customer.descriptive_name FROM customer');"))+ assert.equal(p[0].results[0].customer.id, '5556667777')+})+test('manager OAuth access still forwards normalized login customer without developer token', () => {+ assert.ok(Array.isArray(result(run(['campaigns','list'], {GOOGLE_ADS_LOGIN_CUSTOMER_ID:'123-456-7890'}, "assert.equal(options.headers['login-customer-id'], '1234567890'); assert.equal(Object.hasOwn(options.headers, 'developer-token'), false);"))))+})+test('preview without developer token has no phantom developer header and no fetch', () => {+ const p = result(run(['account','info','--dry-run'], {}, "throw new Error('unexpected fetch')"))+ assert.equal(p._dry_run, true); assert.equal(p.headers.Authorization,'***')+ assert.equal(Object.hasOwn(p.headers,'developer-token'),false)+})+test('legacy developer token remains optional and forwarded when supplied', () => {+ assert.ok(Array.isArray(result(run(['account','info'], {GOOGLE_ADS_DEVELOPER_TOKEN:'legacy-token'}, "assert.equal(options.headers['developer-token'], 'legacy-token');"))))+})+test('legacy developer token preview stays masked', () => {+ const p = result(run(['account','info','--dry-run'], {GOOGLE_ADS_DEVELOPER_TOKEN:'legacy-token'}, "throw new Error('unexpected fetch')"))+ assert.equal(p.headers['developer-token'],'***'); assert.doesNotMatch(JSON.stringify(p),/legacy-token|test-token/)+})+for (const name of ['GOOGLE_ADS_TOKEN','GOOGLE_ADS_CUSTOMER_ID']) test(`${name} remains required`, () => {+ const r = run(['account','info'], {[name]:undefined}, "throw new Error('unexpected fetch')")+ assert.equal(r.status,1); assert.equal(r.stdout,''); assert.match(JSON.parse(r.stderr).error,new RegExp(name))+})+test('help still runs without credentials', () => {+ const r = run([], {GOOGLE_ADS_TOKEN:undefined,GOOGLE_ADS_CUSTOMER_ID:undefined}, "throw new Error('unexpected fetch')")+ assert.equal(result(r).error,'Unknown command')+})diff --git a/tools/clis/google-ads.js b/tools/clis/google-ads.jsindex 2dd87b8..bce5037 100755--- a/tools/clis/google-ads.js+++ b/tools/clis/google-ads.js@@ -7,20 +7,20 @@ const CUSTOMER_ID = process.env.GOOGLE_ADS_CUSTOMER_IDconst LOGIN_CUSTOMER_ID = process.env.GOOGLE_ADS_LOGIN_CUSTOMER_ID?.replace(/-/g, '')const BASE_URL = 'https://googleads.googleapis.com/v24'-if ((!TOKEN || !DEV_TOKEN || !CUSTOMER_ID) && rawArgs.length > 0) {- console.error(JSON.stringify({ error: 'GOOGLE_ADS_TOKEN, GOOGLE_ADS_DEVELOPER_TOKEN, and GOOGLE_ADS_CUSTOMER_ID environment variables required' }))+if ((!TOKEN || !CUSTOMER_ID) && rawArgs.length > 0) {+ console.error(JSON.stringify({ error: 'GOOGLE_ADS_TOKEN and GOOGLE_ADS_CUSTOMER_ID environment variables required' }))process.exit(1)}async function api(method, path, body) {const headers = {'Authorization': `Bearer ${TOKEN}`,- 'developer-token': DEV_TOKEN,'Content-Type': 'application/json',}+ if (DEV_TOKEN) headers['developer-token'] = DEV_TOKENif (LOGIN_CUSTOMER_ID) headers['login-customer-id'] = LOGIN_CUSTOMER_IDif (args['dry-run']) {- return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***', 'developer-token': '***' }, body: body || undefined }+ return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***', ...(DEV_TOKEN ? { 'developer-token': '***' } : {}) }, body: body || undefined }}const res = await fetch(`${BASE_URL}${path}`, {method,diff --git a/tools/integrations/google-ads.md b/tools/integrations/google-ads.mdindex 890fa0b..14b0122 100644--- a/tools/integrations/google-ads.md+++ b/tools/integrations/google-ads.md@@ -8,7 +8,7 @@ Pay-per-click advertising platform for search, display, and video campaigns.|-------------|-----------|-------|| API | ✓ | Google Ads API for campaign management || MCP | ✓ | Available via Google Ads MCP server |-| CLI | - | Use gcloud or API scripts |+| CLI | ✓ | Repository zero-dependency Node.js CLI || SDK | ✓ | Client libraries for multiple languages |## Authentication@@ -16,7 +16,20 @@ Pay-per-click advertising platform for search, display, and video campaigns.- **Type**: OAuth 2.0- **Scopes**: `https://www.googleapis.com/auth/adwords`- **Setup**: Create credentials in Google Cloud Console, link to Google Ads account-- **Headers**: `developer-token`, `login-customer-id` (for MCC)+- **Headers**: `Authorization: Bearer <access_token>`; `login-customer-id` when acting through a manager account+- **API access**: Google Ads API access is assigned to the Google Cloud project that owns your OAuth credentials. Developer tokens were sunset on September 9, 2026; the `developer-token` header is now optional and ignored. Apply for the appropriate project access level in Google Cloud Console, not the retired manager-account API Center process. [Official migration guide](https://developers.google.com/google-ads/api/docs/api-policy/developer-token).++### Repository CLI credentials++The repository's [Google Ads CLI](../clis/google-ads.js) uses `GOOGLE_ADS_TOKEN` (OAuth access token) and `GOOGLE_ADS_CUSTOMER_ID` (target customer ID without hyphens). Set `GOOGLE_ADS_LOGIN_CUSTOMER_ID` when access goes through a manager; it is normalized to digits. Existing setups can still supply `GOOGLE_ADS_DEVELOPER_TOKEN`, but new setups do not need it. The CLI consumes an access token; it does not exchange or refresh OAuth tokens for you. OAuth scopes, user access to the target account, and the Cloud project's API access level remain required.++Use a read-only first call after selecting the intended account:++```bash+node tools/clis/google-ads.js account info+```++A successful response verifies this read's access; it does not establish permission for campaign edits or budget changes.## Common Agent Operations