Install ‘td’ Command

Install the newest TD Toolbelt.

Create Google OAuth2 Credentials

Complete the following steps to create OAuth credentials (client_id & client_secret):

  1. Open Google API Console Credentials: https://console.developers.google.com/apis/credentials

  2. From the project drop-down (upper left corner), click New Project, enter a name for the project, and optionally, edit the provided Project ID. Click Create.


  1. On the Credentials page, Create credentials tab, select OAuth client ID.

  2. You may be prompted to set a product name on the Consent screen; if so, select Configure consent screen, supply the requested information, and click Save to return to the Credentials screen.

  3. Select "Web Application" for the Application Type. Provide a name for your OAuth credentials. Make sure that you add the Google OAuth playground URL to "Authorized redirect URIs":

https://developers.google.com/oauthplayground


  1. Select Create.

  2. Copy the client ID and client secret to your clipboard. You will need the information when you configure your connector job.


See more information on Google credentialing.

Authorize Ads Account to OAuth Credentials

You can use Google OAuth Playground to generate refresh_token from OAuth credentials. This process is to authorize your OAuth app, to access your Ads account.

  1. Go to: https://developers.google.com/oauthplayground

  2. Select Settings in the upper right corner and check Use your own OAuth credentials.

  3. Input "OAuth Client ID" & "OAuth Client Secret" from the preceding section

  4. Input required scopes (OAuth2 permissions) with:

https://www.googleapis.com/auth/adwords https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email


  1. Select Authorize APIs and login to your Google Ads account.

  2. You are redirected back to OAuth2 Playground, select Exchange authorization codes for tokens.


Prepare Query Command

Add the Google Ads Remarketing result output destination by using the -r / --result option for the td query command:

$ td query -d mydb 'SELECT email FROM app_users' -r '{"type":"google_adwords","client_id":"773#######################################j33.apps.googleusercontent.com","client_secret":"A######################N","developer_token":"9####################Q","refresh_token":"1/CG#######################################KI","client_customer_id":"111-222-3333","name":"abc_app_user_list","description":"User list from mobile app abc","app_id":"abc","mode":"append","membership_lifespan":10000,"batch_size":100000,"maximum_retries":5,"initial_retry_interval_millis":500,"maximum_retry_interval_millis":300000}'

Where:

  • client_id: (required) Your Google OAuth2 credentials 

  • client_secret: (required) Your Google OAuth2 credentials 

  • refresh_token: (required) Your Google OAuth2 credentials 

  • developer_token: (required) Your Google Ads Developer Token 

  • client_customer_id: (required) Your Google Ads Customer ID. Format: nnn-nnn-nnnn where n is a digit.

  • name: (required) Name of the user list

  • description: (optional) Description of the user list. Default: empty.

  • app_id: Mobile Application ID (only required for mobile_id export)

  • mode: (optional) Upload mode. Default: append. Supported values:

    • append

    • replace

    • remove
  • membership_lifespan: (optional) Number of days users' contact info stays on the user list. Default: 10000.

  • batch_size: (optional) Number of records to upload in each batch. Default: 100000.

  • maximum_retries: (optional) Number of retries before system gives up. Default: 5.

  • initial_retry_interval_millis: (optional) Initial retry time wait in milliseconds. Default: 500, which is equivalent to 0.5 seconds.

  • maximum_retry_interval_millis: (optional) Max retry wait in milliseconds. Default: 300000, which is equivalent to 5 minutes.


  • No labels