RE: Adwords API to googleads migration

56 views
Skip to first unread message
Message has been deleted

Google Ads API Forum Advisor

unread,
Nov 9, 2021, 12:33:12 AM11/9/21
to fhy...@smartasset.com, adwor...@googlegroups.com

Hello Fahima,

Thank you for reaching out to us.

Looking on the error encountered, you would need to enable the Google Ads API in your project. You can check on this guide for more details.

As an aside, I will be removing your original post as it contains Google Cloud project information. Please refrain from sharing these information in the forum thread. Below is a copy of your post with the masked details.

I'm trying to run the following script

import argparse
import sys

from google.ads.googleads.client import GoogleAdsClient

from google.ads.googleads.errors import GoogleAdsException

def main(client, customer_id):

ga_service = client.get_service("GoogleAdsService")

query = """

SELECT
campaign.id,
campaign.name
FROM campaign
ORDER BY 
campaign.id"""

# Issues a search request using streaming.

stream = ga_service.search_stream(customer_id=customer_id, query=query)

for batch in stream:

for row in batch.results:

print(

f"Campaign with ID {row.campaign.id} and name "

f'"{row.campaign.name}" was found.'

)

if __name__ == "__main__":

# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.

googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description="Lists all campaigns for specified customer."
)

# The following argument(s) should be provided to run the example.

parser.add_argument(
"-c",
"--customer_id",
type=str,
required=True,
help="The Google Ads customer ID.",
)

args = parser.parse_args()

try:
main(googleads_client, args.customer_id)
except GoogleAdsException as ex:

print(

f'Request with ID "{ex.request_id}" failed with status '

f'"{ex.error.code().name}" and includes the following errors:'
)

for error in ex.failure.errors:

print(f'\tError with message "{error.message}".')

if error.location:

for field_path_element in error.location.field_path_elements:

print(f"\t\tOn field: {field_path_element.field_name}")

sys.exit(1)

For the "customer_id" I'm plugging in the client customer ID that was provided with my adwords credentials, it's formatted as "###=###=####"

I keep receiving the following error
google.api_core.exceptions.PermissionDenied: 403 Google Ads API has not been used in project ###### before or it is disabled. Enable it by visiting <Google Cloud link> then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
I've reached out to the owner of the manager account and he's unable to change the permissions. Can you please assist? 


Regards,

Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey
 

Google Logo
Mark Kevin Albios
Google Ads API Team
 


ref:_00D1U1174p._5004Q2R7IvX:ref
Reply all
Reply to author
Forward
0 new messages