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
feat: support Google Ads manager account authorization context
Rudy Celekli6802d4949f38
diff --git a/tests/clis/google-ads-manager.test.cjs b/tests/clis/google-ads-manager.test.cjsnew file mode 100644index 0000000..57b84e6--- /dev/null+++ b/tests/clis/google-ads-manager.test.cjs@@ -0,0 +1,30 @@+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, oracle = '', env = {}) {+ const code = `global.fetch = async (url, options) => {+ const assert = require('node:assert/strict');+ const parsed = new URL(url);+ const body = options.body ? JSON.parse(options.body) : null;+ ${oracle}+ return new Response(JSON.stringify({accepted:true, url, body}), {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_DEVELOPER_TOKEN:'test-developer', GOOGLE_ADS_CUSTOMER_ID:'5556667777', ...env}+ for (const [key, value] of Object.entries(childEnv)) if (value === undefined) delete childEnv[key]+ const r = spawnSync(process.execPath, ['-e', code], {encoding:'utf8', env:childEnv, timeout:10000})+ return r+}+function result(r) { assert.equal(r.status,0,r.stderr); return JSON.parse(r.stdout) }+for (const args of [['campaigns','list'],['campaigns','pause','--id','42']]) test(`${args[1]} forwards manager access context`, () => {+ const p = result(run(args, "assert.equal(options.headers['login-customer-id'], '1234567890'); assert.ok(parsed.pathname.startsWith('/v24/customers/5556667777/'));", {GOOGLE_ADS_LOGIN_CUSTOMER_ID:'123-456-7890'}))+ assert.equal(p.accepted,true)+})+test('direct account request does not gain an unnecessary manager header', () => {+ assert.equal(result(run(['account','info'], "assert.equal(options.headers['login-customer-id'], undefined);", {GOOGLE_ADS_LOGIN_CUSTOMER_ID:undefined})).accepted,true)+})+test('manager preview includes normalized header and masks credentials', () => {+ const p = result(run(['campaigns','list','--dry-run'], "throw new Error('unexpected fetch')", {GOOGLE_ADS_LOGIN_CUSTOMER_ID:'123-456-7890'}))+ assert.equal(p.headers['login-customer-id'],'1234567890'); assert.equal(p.headers.Authorization,'***'); assert.equal(p.headers['developer-token'],'***')+})diff --git a/tools/clis/google-ads.js b/tools/clis/google-ads.jsindex 27e5431..468fa49 100755--- a/tools/clis/google-ads.js+++ b/tools/clis/google-ads.js@@ -3,6 +3,7 @@const TOKEN = process.env.GOOGLE_ADS_TOKENconst DEV_TOKEN = process.env.GOOGLE_ADS_DEVELOPER_TOKENconst CUSTOMER_ID = process.env.GOOGLE_ADS_CUSTOMER_ID+const 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) {@@ -11,16 +12,18 @@ if (!TOKEN || !DEV_TOKEN || !CUSTOMER_ID) {}async function api(method, path, body) {+ const headers = {+ 'Authorization': `Bearer ${TOKEN}`,+ 'developer-token': DEV_TOKEN,+ 'Content-Type': 'application/json',+ }+ if (LOGIN_CUSTOMER_ID) headers['login-customer-id'] = LOGIN_CUSTOMER_IDif (args['dry-run']) {- return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'developer-token': '***', 'Content-Type': 'application/json' }, body: body || undefined }+ return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***', 'developer-token': '***' }, body: body || undefined }}const res = await fetch(`${BASE_URL}${path}`, {method,- headers: {- 'Authorization': `Bearer ${TOKEN}`,- 'developer-token': DEV_TOKEN,- 'Content-Type': 'application/json',- },+ headers,body: body ? JSON.stringify(body) : undefined,})const text = await res.text()diff --git a/tools/integrations/google-ads.md b/tools/integrations/google-ads.mdindex e1e01ca..890fa0b 100644--- a/tools/integrations/google-ads.md+++ b/tools/integrations/google-ads.md@@ -243,3 +243,12 @@ LIMIT 200- ads- analytics- cro++### Manager account access in the CLI++When OAuth credentials access a client through a manager account, set+`GOOGLE_ADS_LOGIN_CUSTOMER_ID` to that manager ID. The CLI removes display hyphens+and sends `login-customer-id` on both report and mutation requests. Keep+`GOOGLE_ADS_CUSTOMER_ID` set to the target client account. Direct client access+does not require the manager variable. See+[Google Ads REST authorization](https://developers.google.com/google-ads/api/rest/auth).