Google Ads API Read campaign data error curl: (22) The requested URL returned error: 403

29 Views Asked by At

I am trying to read adwords accounts campaigns/adset/ads data programmatically. I have generated developer token and created oauth 2 client and got refresh and access token programmatically using this link .

While testing the tokens using curl by getting campaign data I am getting below error.

Curl Command:

curl -f --request POST "https://googleads.googleapis.com/v14/customers/8928712959/googleAds:searchStream" \
--header "Content-Type: application/json" \
--header "developer-token: xxxxxxxxxxx" \
--header "login-customer-id: xxxxxxxxxxx" \
--header "Authorization: Bearer xxxxxxxxxx" \
--data '{
"query": "
  SELECT campaign.name,
    campaign_budget.amount_micros,
    campaign.status,
    campaign.optimization_score,
    campaign.advertising_channel_type,
    metrics.clicks,
    metrics.impressions,
    metrics.ctr,
    metrics.average_cpc,
    metrics.cost_micros,
    campaign.bidding_strategy_type
  FROM campaign
  WHERE segments.date DURING LAST_7_DAYS
    AND campaign.status != 'REMOVED'
"
}'

Error: curl: (22) The requested URL returned error: 403

I have added relevant permission too in oauth2 app as you can see in the screenshots below. enter image description here enter image description here

Can anyone help me if I am doing something wrong? Am I Generating wrong access token or something?

0

There are 0 best solutions below