Posts tagged with google-api-client

I am using google-ads-api. My goal is to get impressions and clicks for specific campaign. These are the things I have done.

  1. created google service account
  2. Downloaded google-ads-library from github
  3. Added clientid , secretid, refresh token to my adsapi.ini file.

When I run the code it gives me error .

Google\ApiCore\ApiException { "message": "The caller does not have permission", "code": 7, "status": "PERMISSION_DENIED", "details": [ { "@type": "type.googleapis.com/google.ads.googleads.v9.errors.GoogleAdsFailure", "errors": [ { "errorCode": { "authorizationError": "USER_PERMISSION_DENIED" }, "message": "User doesn't have permission to access customer. Note: If you're accessing a client customer, the manager's customer id must be set in the 'login-customer-id' header. See https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid" } ], "requestId": "pKHgfIr99F5XApaPFBnrLQ" } ] }

my adsapi.ini

[GOOGLE_ADS] ; Required Google Ads properties. name = "Google Ads" developerToken = "*****-*******_*" ; Optional. Set a friendly application name identifier. userAgent = "Scraper" ; Optional additional AdWords API settings. ; endpoint = "https://adwords.google.com/" ; isPartialFailure = false ; Optional setting for utility usage tracking in the user agent in requests. ; Defaults to true. ; includeUtilitiesInUserAgent = true [ADWORDS_REPORTING] ; Optional reporting settings. ; isSkipReportHeader = false ; isSkipColumnHeader = false ; isSkipReportSummary = false ; isUseRawEnumValues = false [OAUTH2] ; Required OAuth2 credentials. Uncomment and fill in the values for the ; appropriate flow based on your use case. See the README for guidance: ; https://github.com/googleads/googleads-php-lib/blob/master/README.md#getting-started ; For installed application or web application flow. clientId = "**********************" clientSecret = "********************" refreshToken = "***********************"  For service account flow. ; jsonKeyFilePath = "INSERT_ABSOLUTE_PATH_TO_OAUTH2_JSON_KEY_FILE_HERE" ; scopes = "https://www.googleapis.com/auth/adwords" ; impersonatedEmail = "INSERT_EMAIL_OF_ACCOUNT_TO_IMPERSONATE_HERE" [SOAP] ; Optional SOAP settings. See SoapSettingsBuilder.php for more information. ; compressionLevel = <COMPRESSION_LEVEL> ; wsdlCache = <WSDL_CACHE> [PROXY] ; Optional proxy settings to be used by SOAP requests. ; host = "<HOST>" ; port = <PORT> ; user = "<USER>" ; password = "<PASSWORD>" [LOGGING] ; Optional logging settings. ; soapLogFilePath = "/soap.log" ; soapLogLevel = "INFO" ; reportDownloaderLogFilePath = "path/to/your/report-downloader.log" ; reportDownloaderLogLevel = "INFO" ; batchJobsUtilLogFilePath = "path/to/your/bjutil.log" ; batchJobsUtilLogLevel = "INFO" 

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# 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#