Search code examples
c#.net-coregoogle-ads-apigoogle-authenticationgoogle-api-client

Google Ads API Integration


The Company I work with has many clients who uses Google Ads to do marketing for their websites. The company wants to use client's data for Analysis. I am given a project to integrate Google Ads API using C# to get all the data such as Campaigns etc from Google ads and move it to our system for each client. I am only given developer token and customerID for Clients. such as

  1. Customer ID for Client A
  2. Customer ID for Client B

I am bit lost when I went through the google ads API documentation. In the documentation, the OAuth2.0 needs creating in order to use client library which would generate client ID and Client Secret, Refresh token to integrate the API. My question is. Do I need to create OAuth2.0 for each client or do I need to ask my company to generate Client ID and secret in company's Manager Account or Client that uses Google ads would provide me these?

The following Link I found to create OAuth2.

https://developers.google.com/google-ads/api/docs/oauth/cloud-project

This is what I believe would require in C# enter image description here Content can be found at https://developers.google.com/adwords/api/docs/guides/first-api-call#.net_1

Would highly appreciate if any one can help me what actually I need to configure google ads using C#


Solution

  • If your company manager account is a manager for the relevant client accounts, you would just need to authenticate as the manager account using your developer token, client id and secret. This gives access to the Ads data for all clients linked under the manager account.

    E.g. calling Google Ads API CustomerService > ListAccessibleCustomers returns a list of customers accessible to the authenticated client.

    Further to comments where you say you will be creating a console app:

    The link in your question says use a desktop application if:

    You're managing all of your Google Ads accounts using a single top level manager account. You're a first-time user, or want to get started quickly with the simplest setup. Your app will only authenticate Google users from one machine.

    So using a manager account which links the required client accounts would be required in this case. See OAuth desktop application flow.

    If you used a web application, the clients could log in and your app could read and store their refresh token in a database to make future calls to the api for their account.