We can't get the campaigns

149 views
Skip to first unread message

Exos Solutions

unread,
Nov 23, 2020, 2:52:15 AM11/23/20
to AdWords API and Google Ads API Forum
Hello everyone,

We are new to developing with Google Ads API. We started a couple of weeks ago with the Google Adwords API, doing the initial tutorial: We created a production Manager Account, then we created a Test Account and with it we created three customers, we obtained the OAuth2 credentials. We create several search and display campaigns for each customer. And we tested the example codes to get the campaigns, everything worked fine.

Later we found out that there was a new version of the API: Google Ads API, so we downloaded the sample codes from the Google Ads API and tried to get the campaigns, it doesn't work. When we test ListAccessibleCustomers it returns the three customers, but when we test GetCampaigns in two of the three customers it tells us that USER_PERMISSION_DENIED or DEVELOPER_TOKEN_NOT_APPROVED and in the third it returns an empty list of campaigns, and the accounts are test accounts. What are we doing wrong? 

Regards,
Gloria M. 

Google Ads API Forum Advisor Prod

unread,
Nov 23, 2020, 10:21:05 PM11/23/20
to exos.sol...@gmail.com, adwor...@googlegroups.com
Hi Gloria,

Thank you for reaching out to our API support team. You may refer below for more information on the errors you encountered :

USER_PERMISSION_DENIED - This may indicate that you are authenticating as a user with access to a manager account but not specifying login-customer-id in the request. To learn more about the login-customer-id, you may refer to this guide.

DEVELOPER_TOKEN_NOT_APPROVED - you would need to request for at least basic access level for your developer token if you would be making calls to your production Google Ads accounts. You may then refer here for the different access levels and the corresponding instructions for submitting a request. 

As for the third issue that did not return any campaigns, and if any of the other issues persist, you may provide your customer ID, and the complete request and response logs so our team can investigate further.

You may send the requested details using the Reply privately to author option.

Best regards,

Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


ref:_00D1U1174p._5004Q27vuY7:ref
Message has been deleted
Message has been deleted

Google Ads API Forum Advisor Prod

unread,
Nov 24, 2020, 9:04:36 PM11/24/20
to exos.sol...@gmail.com, adwor...@googlegroups.com
Hi Gloria,

Thank you for these details. However, I had to remove one of your earlier responses once again due to it containing your account information. If you would be unable to reply to us privately, you may send any requested details containing sensitive information to our googleadsa...@google.com alias instead.

Dear Peter,
Thanks for your quick response. I reply to all because "Reply privately to author" option disabled.
I'll tell you about the problem in more detail. I created an MCC production account (with test developer token), from that account I created a test account, from the test account I created 3 customer accounts, in each customer account I created several campaigns of different types.

I also got the OAuth2 credentials (Client ID, Client Secret) for the MCC production account and the refresh token.
With all these parameters I configured the ads.properties of the Google Adwords API and I ran several utilities that worked well for me. I also passed the parameters with programming and it kept working fine.
Then I downloaded the Google Ads API libraries and examples and set up the ads.properties in a similar way, as indicated in the guide. But I don't get results. My test customers are:
Cliente 1: XXXXXXXXX
Cliente de prueba 1: XXXXXXXXX
XXXXXXXXX: XXXXXXXXX
The code that I use to connect with Google Ads is that of GetCampaigns as follows:

 UserCredentials credentials = UserCredentials.newBuilder()
            .setClientId(mccClientId)
            .setClientSecret(mccClientSecret)
            .setRefreshToken(mccRefreshToken)
            .build();
GoogleAdsClient gaClient = GoogleAdsClient.newBuilder()
            .setDeveloperToken(mccDeveloperToken)
            .setCredentials(credentials)
            .setLoginCustomerId(Long.valueOf(clientCustomerId.replace("-", "")))
            .build();
try (GoogleAdsServiceClient googleAdsServiceClient = gaClient.getLatestVersion()
            .createGoogleAdsServiceClient()) {

          String query = "SELECT campaign.idcampaign.name FROM campaign ORDER BY campaign.id";
          
          SearchGoogleAdsStreamRequest request = SearchGoogleAdsStreamRequest.newBuilder()
              .setCustomerId(clientCustomerId.replace("-", ""))
              .setQuery(query)
              .build();

          ServerStream<SearchGoogleAdsStreamResponse> stream = googleAdsServiceClient
              .searchStreamCallable()
              .call(request);

          for (SearchGoogleAdsStreamResponse response : stream) {
            for (GoogleAdsRow googleAdsRow : response.getResultsList()) {
              System.out.printf("Campaign with ID %d and name '%s' was found.%n",
                  googleAdsRow.getCampaign().getId(), googleAdsRow.getCampaign().getName());
            }
          }
        }
      }
In the clientCustomerId variable I pass the previous Customer IDs without hyphens and it returns the USER_PERMISSION_DENIED error for all cases.
I have run the code from ListAccessibleCustomers and it gives me other different IDs:
"Total results: 3
Customer resource name: customers / XXXXXXXXX
Customer resource name: customers / XXXXXXXXX
Customer resource name: customers / XXXXXXXXX

I have also tried to pass these IDs and the result is the same, except for the last one that returns an empty list of campaigns.

We have already requested the Basic Token, but at the moment we do not have it. What surprises me is that with Google Adwords API test accounts work well and with Ads API nothing works.
Any idea what I'm doing wrong? 


Moving forward, and based on your most recent response, could you confirm if your issues have now been resolved and if there is anything our team can further assist with?

Exos Solutions

unread,
Nov 25, 2020, 3:38:49 AM11/25/20
to AdWords API and Google Ads API Forum
Hi Peter,

Thanks for your corrections. This issue is resolved, but I have other questions that I would like to consult you, do I put them in this thread or do I open another conversation?.
The doubts are about how to obtain various statistical data. 

Regards,
Gloria Muñoz.

Google Ads API Forum Advisor Prod

unread,
Nov 25, 2020, 10:09:55 AM11/25/20
to exos.sol...@gmail.com, adwor...@googlegroups.com
Hi Gloria,

For better tracking purposes, please create a new thread regarding any other issues.

Regards,
Anthony
Google Ads API Team

Google Logo
Anthony
Google Ads API Team
 


ref:_00D1U1174p._5004Q27vuY7:ref
Reply all
Reply to author
Forward
0 new messages