How to Connect to the Google Ads API Using Python
The Google Ads API is a powerful tool that allows advertisers and developers to access and manage their Google Ads accounts and campaigns programatically. It enables you to automate processes, gather campaign insights, and create custom solutions tailored to your business needs. Working at Google, I get asked quite often for step by step instructions on how to connect to setup the Google Ads API.
In this blog post, I will walk you through the process of connecting to the Google Ads API so you can harness its potential and unlock new opportunities for your advertising endeavors. We will also walk through testing the API using the Google Ads API python client library.
Generate a Developer Token
1- Create a Google Ads Manager (MCC) Account
In order to generate a developer token, you would need a Google Ads Manager account. Create a Google Ads Manager account via https://ads.google.com/home/tools/manager-accounts
Google Ads Manager accounts allow you to access multiple Google Ads accounts including other manager accounts, manage their campaigns, and generate Developer Tokens. The manager account holds the developer token and does not dictate which accounts can the developer token can access. After creating the manager account (unless you already have one) you could then create a test account, or use a regular account with some paused or enabled campaigns that we can use later on for testing.
2- Generate a Google Ads Developer Token
Go to your Google Ads ‘Tools & Settings’ menu item, and click on API Center. There you will be able to see your developer token. The initial signup will generate a Test Access level. For production accounts, Basic Access or Standard Access levels must be requested.
Configure Your Google Cloud Account and OAuth credentials
1- Create a Google Cloud project
In case you do not already have a GCP project. Create one by visiting console.cloud.google.com/cloud-resource-manager, and clicking on ‘+CREATE PROJECT’.
2- Enable the Google Ads API in your project
In your GCP project, navigate to ‘APIs & Services’, and click on +Enable APIs & Services, search for the Google Ads API, and click Enable.
3- Configure OAuth credentials on GCP
OAuth2 lets your app operate on behalf of your account. Also under APIs & Services, navigate to Credentials, click on ‘+CREATE CREDENTIALS’, select OAuth Client ID. If this is your first time setting it up, you will be asked to configure the consent screen. Choose ‘Internal’ and press ‘Create’, fill in an App Name and user support email and developer contact information, and press ‘Save & Continue’.
Go back to ‘+CREATE CREDENTIALS’, choose Web Application, fill in a name, and use https://developers.google.com/oathplayground for the ‘Authorized redirect URI’, and the click on the ‘Create’ button.
Copy or download the created Client Id and Client secret values to a safe location.
4- Generate an OAuth refresh token
Navigate to https://developers.google.com/oathplayground, on the settings button (right upper corner on the time of writing this), select the checkbox ‘Use your own OAuth credentials’, and fill in your client id and client secret.
Select the Google Adwords API from the list on the left, and click on the Authorize APIs button. Select ‘Allow’, and select ‘Exchange authorization code for token’ to get your developer token.
You’re all done!
Let’s test it out:
Test your access
1- Install the Google Ads Python module
Please refer to the documentation on how to configure python on your machine in case it is not already installed. Then use the following command to install the google ads python module:
pip install google-ads
2- Create and Configure a google-ads.yaml config file
Create a google-ads.yaml file using the template found here: https://github.com/googleads/google-ads-python/blob/HEAD/google-ads.yaml
3- Run a test script to pull campaigns by lable (or any other test script).
This example script uses Google Ads Query language to retrieve campaigns by label, you could modify the query inside to retrieve all campaigns.
There are tons of examples on using the python api library with google ads here: https://github.com/googleads/google-ads-python/tree/main/examples
Add the google-ads-config.yaml file and the test script to the same folder and run the following command (assuming your test script is get_campaigns_by_label.py)
python get_campaigns_by_label.py
Disclaimer: My posts and opinions are my own, not those of my company (Google).






