Skip to content

Instantly share code, notes, and snippets.

@limata3
Last active July 7, 2021 12:00
Show Gist options
  • Select an option

  • Save limata3/a39853cfb2c05141efcba856e07b0d9f to your computer and use it in GitHub Desktop.

Select an option

Save limata3/a39853cfb2c05141efcba856e07b0d9f to your computer and use it in GitHub Desktop.
from googleads import adwords
from googleads import oauth2
def connect_to_adwords_api():
customer_id = 'xxx-xxx-xxxx' # This is client customer ID you see in the google ads UI
oauth2_client = oauth2.GoogleRefreshTokenClient(
client_id={GOOGLE_CLIENT_ID},
client_secret={GOOGLE_CLIENT_SECRET},
refresh_token={GOOGLE_REFRESH_TOKEN}
)
adwords_client = adwords.AdWordsClient(
developer_token={GOOGLE_DEVELOPER_TOKEN},
oauth2_client=oauth2_client,
user_agent='marketing_data',
client_customer_id=customer_id
)
return adwords_client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment