Posts tagged with google-ads-api

The production instance of my android app has been crashing. The stack trace isn't much useful. The crash may be coming off of com.google.android.gms.common.GooglePlayServicesUtilLight.getRemoteContext but it may not be the ultimate culprit. Pasting the stack trace below:

Fatal Exception: java.lang.RuntimeException: android.os.DeadSystemException        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:746)        at android.app.LoadedApk.access$100(LoadedApk.java:99)        at android.app.LoadedApk$SplitDependencyLoaderImpl.constructSplit(LoadedApk.java:597)        at android.content.pm.split.SplitDependencyLoader.loadDependenciesForSplit(SplitDependencyLoader.java:70)        at android.app.LoadedApk$SplitDependencyLoaderImpl.ensureSplitLoaded(LoadedApk.java:632)        at android.app.LoadedApk$SplitDependencyLoaderImpl.getSplitPathsForSplit(LoadedApk.java:641)        at android.app.LoadedApk.getSplitPaths(LoadedApk.java:658)        at android.app.ContextImpl.createResources(ContextImpl.java:2152)        at android.app.ContextImpl.createPackageContextAsUser(ContextImpl.java:2214)        at android.app.ContextImpl.createPackageContext(ContextImpl.java:2193)        at android.content.ContextWrapper.createPackageContext(ContextWrapper.java:884)        at com.google.android.gms.common.GooglePlayServicesUtilLight.getRemoteContext(GooglePlayServicesUtilLight.java:125)        at com.google.android.gms.internal.ads.zzabl.initialize(zzabl.java:23)        at com.google.android.gms.internal.ads.zzabp.zzi(zzabp.java:15)        at com.google.android.gms.internal.ads.zzabo.get(zzabo.java:11)        at com.google.android.gms.ads.internal.util.zzbr.zza(zzbr.java:13)        at com.google.android.gms.internal.ads.zzabp.initialize(zzabp.java:1)        at com.google.android.gms.internal.ads.zzamy.run(zzamy.java:2)        at java.lang.Thread.run(Thread.java:919) 

Please take a look and let me know if any more details are required to be shared. I am using the following dependencies for google ads API:

implementation 'com.google.android.gms:play-services-ads:19.7.0' implementation group: 'com.github.ankitbatra11', name: 'billboard', version: '2.0.1' implementation group: 'com.google.ads.mediation', name: 'facebook', version: '6.2.0.1' implementation group: 'com.google.ads.mediation', name: 'adcolony', version: '4.4.0.0' 

I am writing an Azure Function in C# using .NET core.

I have tried to authenticate as an APPLICATION per this page.

I've tried authenticating with a service account per this page.

In both cases I'm getting an access denied error message.

The root question I have is,

Which authentication method should I use for the Google Ads API from within an Azure Function?

Update:

In my latest attempt to use a service account I have this code

GoogleAdsConfig config = new GoogleAdsConfig()             {            OAuth2Mode = Google.Ads.GoogleAds.Config.OAuth2Flow.SERVICE_ACCOUNT,            OAuth2SecretsJsonPath = pathtojsonfile,            OAuth2PrnEmail = "something@somethingelse.iam.gserviceaccount.com",            OAuth2Scope = "https://www.googleapis.com/auth/adwords",            DeveloperToken = "********"         };                  var responseMessage = "";         var client = new GoogleAdsClient(config);                  // Get the GoogleAdsService.         GoogleAdsServiceClient googleAdsService = client.GetService(Services.V6.GoogleAdsService);         // Create the query.         string query =             @"SELECT              campaign.id,              campaign.name,              ad_group.id,              ad_group.name,              ad_group_criterion.criterion_id,              ad_group_criterion.keyword.text,              ad_group_criterion.keyword.match_type,              metrics.impressions,              metrics.clicks,              metrics.cost_micros          FROM keyword_view          WHERE segments.date DURING LAST_7_DAYS              AND campaign.advertising_channel_type = 'SEARCH'              AND ad_group.status = 'ENABLED'              AND ad_group_criterion.status IN ('ENABLED','PAUSED')          ORDER BY metrics.impressions DESC          LIMIT 50";         try         {             // Issue a search request.             await googleAdsService.SearchStreamAsync(customerId.ToString(), query,                 delegate (SearchGoogleAdsStreamResponse resp)                 {                     // Display the results.                     foreach (GoogleAdsRow criterionRow in resp.Results)                     {                         responseMessage +=                             "Keyword with text " +                             $"'{criterionRow.AdGroupCriterion.Keyword.Text}', match type " +                             $"'{criterionRow.AdGroupCriterion.Keyword.MatchType}' and ID " +                             $"{criterionRow.AdGroupCriterion.CriterionId} in ad group " +                             $"'{criterionRow.AdGroup.Name}' with ID " +                             $"{criterionRow.AdGroup.Id} in campaign " +                             $"'{criterionRow.Campaign.Name}' with ID " +                             $"{criterionRow.Campaign.Id} had " +                             $"{criterionRow.Metrics.Impressions.ToString()} impressions, " +                             $"{criterionRow.Metrics.Clicks} clicks, and " +                             $"{criterionRow.Metrics.CostMicros} cost (in micros) during the " +                             "last 7 days.";                     }                 }             );         }         catch (GoogleAdsException e)         {             responseMessage += "Failure:\n";             responseMessage += $"Message: {e.Message}\n";             responseMessage += $"Failure: {e.Failure}\n";             responseMessage += $"Request ID: {e.RequestId}\n";             throw;         }         return responseMessage; 

When I call this I get the following error:

{     "StatusCode": 16,     "Details": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",     "RequestId": "0Yk2OYrUATjwftZ5I0qi2g",     "Failure": {       "errors": [         {           "errorCode": {             "authenticationError": "NOT_ADS_USER"           },           "message": "User in the cookie is not a valid Ads user."         }       ]     }   }   

I have the service account set up with the Google Ads API Enabled. Why does it think I'm "NOT AN ADS USER" ???

Hi I have been using rest methods to integrate Google Ads API in C#. Everything seemed to be working fine but all of sudden I started getting 400 response with the error message.

{     "error": "invalid_grant",     "error_description": "Token has been expired or revoked." } 

As mentioned above that I am not using client library but instead using restsharp and testing all my end points using postman also.

Any reason why it is happening? My refresh token is also valid. I have been using this for one week. I have also not reached to the limit of refresh token as I have only generated refresh token 3 to 4 times when I was trying to set up the accounts.

I believe the validity of refresh token is life long then why it is happening?

I am having a problem with a data transfer from Google Ads. When I schedule the backfill I get the following error for some dates:

Invalid value: Load configuration must specify at least one source URI

When I check the log inside of the details of execution I get the following message:

Failed to start job for table p_ClickStats_5419416216$20201117 with error INVALID_ARGUMENT: Invalid value: Load configuration must specify at least one source URI

The weird part is that this happens for random dates which I had transfered before in a previous transfer. Did anyone have a problem similar to that?

Using Google Ads API "Get Account Hierarchy" to get all accounts. https://developers.google.com/google-ads/api/docs/account-management/get-account-hierarchy?hl=en

Found out that canceled accounts are not being retrieved.

I do see the canceled accounts are being reported in the UI and in their Google Data Studio connector. I guess both use the old AdWords API.

Is there a way to fetch and report canceled accounts via Google Ads API? Is it recommended to use the old AdWords API?