Google Ads
  • 02 Sep 2024
  • 3 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Google Ads

  • Dark
    Light
  • PDF

Article summary

The Google Ads API is a powerful tool that allows developers to interact programmatically with Google Ads accounts. It provides a way to automate tasks, build custom reporting tools, and integrate Google Ads data with other systems.

Key features of the Google Ads API include:

  • Account management
  • Campaign and ad group creation and modification
  • Keyword and targeting management
  • Reporting and performance data retrieval
  • Billing and budget management

To start using the Google Ads API:

  1. Create a project in Google Cloud Console.
  2. Create an OAuth client.
  3. Obtain an authorization code.
  4. Receive access and refresh tokens.
  5. (Optional) Get Google Ads developer token.

1. Create project in Google Cloud Console

To create a project in Google Cloud Console:

  1. Go to Google Cloud Console and sign in with your Google account.
    Main page

  2. Create a new project or select an existing one by clicking My First Project and then clicking Dashboard.
    My first project

  3. On the left navigation panel, click APIs & Services and from the dropdown list, select Library.
    LIbrary in list

  4. In the search field of the API Library page, enter Google Ads API and in the list, click Google Ads API.
    Google ads api in list

  5. On the Product details page, click Enable.
    Enable button

Your project has been created.

2. Create OAuth client

To create OAuth client:

  1. On the API/Service Details page, click Credentials.
    Credentials tab

  2. On the Credentials page, click + Create Credentials and in the dropdown list, select OAuth client ID.
    OAuth clint ID in list

  3. On the right side of the Create OAuth client ID page, click Configure Consent Screen.
    Configure consent screen

  4. On the OAuth consent screen page, select a user type (Internal or External) and click Create.
    User type

  5. On the Create OAuth client ID page:

    1. Select the Web application type in the Application type dropdown list.
    2. Enter a name in the Name field.
    3. Below Authorized redirects URls, click Add URI and enter the http://localhost:8000/callback URI in the URls 1 field.
      Note: This is the URI to which the user will be redirected after authorization.
    4. Click Create.
      Create OAuth page

The OAuth client has been created.
Note: You can download the file by clicking Download JSON.

OAuth client created

3. Obtain authorization code

To obtain an authorization code:

  1. Go to the https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&scope=https://www.googleapis.com/auth/adwords&access_type=offline URL.
  2. Replace YOUR_CLIENT_ID with your Client ID and YOUR_REDIRECT_URI with your redirect URI (that you’ve specified in step 5 of Create OAuth client).
  3. Copy the code from your URL: the piece from ?code till &scope.
    URL

You have the authorization code that you can use in the Corezoid process for receiving access and refreshing tokens.

4. Receive access and refresh tokens

To receive an access and refresh tokens:

  1. Go to Corezoid.com and create a process with an API Call node with the POST API request.
    Process with Post API request

  2. On the API Call node details panel:

    1. Enter Create access/refresh token in the Add title field.
    2. Enter "https://www.googleapis.com/oauth2/v4/token" in the URL field.
    3. Select Default in the Request format dropdown list.
    4. Select POST in the Request method dropdown list.
    5. Select json in the Data format dropdown list.
    6. Enter "application/json; charset=utf-8" in the Content-Type field.
    7. Enter redirect_uri, grant_type, client_id, code, and client_secret in the Key fields.
    8. Enter https://localhost:300, authorization_code, client ID (can be found in the json file you downloaded), code (that you obtained in Obtain authorization code, step 3), and client secret (can be found in the json file you downloaded) in the Value fields.

POST API request details

  1. After you receive your access and refresh the token, create another API Call node and on its details panel:
    a. Enter Refresh access token to the Add title field.
    b. Enter "https://www.googleapis.com/oauth2/v4/token" in the URL field.
    c. Select Default in the Request format dropdown list.
    d. Select POST in the Request method dropdown list.
    e. Enter Application/X-Www-Form-Urlencoded in the Content-Type field.
    f. Enter "refresh_token", "grant_type", "client_id", and "client_secret" in the Key fields.
    g. Enter "refresh_token", {{client_id}}, and {{client_secret}} in the Value fields.

    Refresh access token

You can call this request with refresh tokens every hour to update your access token and use it in API requests for Google Ads.

5. Get Google Ads developer token

To get a Google Ads developer token:

  1. On the left navigation panel of the Google Ads main page, click Administrator, and from the dropdown list, select API Center.
    API Center in list

  2. Fill in the API Access form:

    1. Enter your API contact email in the API Contact Email field.
    2. Enter your company name in the Company name field.
    3. Enter your company website URL in the Company website URL field.
    4. Select your company type checkbox (Advertiser, Search Engine Marketing Agency/Company, Partner, or Independent Google Ads Developer).
    5. Describe your plan in the Intended use field.
    6. Select your country in the Primary country of business activity dropdown list.
    7. Select the I accept these Terms of Use checkbox.
    8. Click Create ID.

    API Access form

The API Access form has been submitted for verification: Google reviews the form and sends you the token by email to access the Google Ads API.


Was this article helpful?

What's Next