I'm having some problems creating a script that automatically retrieves 
some metrics from Google Ads for a daily report for the company I work in.
I've been reading tens of pages of documentation, troubleshooting and help, 
but unfortunately they only increased my confusion.
Initially, we only had a Google Ads account, that we use to manage ad 
campaigns. This is what I did next:

   1. I created an Ad Manager account, and successfully associated it to 
   our Google Ads account, in order to have access to the Google Ads API.
   2. I requested access to the API and, long story short, I now have 
   access at the *basic* level.
   3. After reading tens of help pages, I decided to use a server-to-server 
   flow. The script I'm creating has to be executed automatically by cronjob, 
   so if I understood correctly I can't use any other authentication method.
   4. I created a new project from the developer console and associated 
   Google Ads API to it.
   5. I created a service account and gave it viewer rights. I didn't 
   enable domain-wide delegation because it requires a G Suite/Google 
   Workspace account, which we don't have, and one of the guides said it's 
   optional.
   6. I generated a JSON key file fr the service account, and saved it on 
   my computer.
   7. I tried a query to test the access. This is a simplified version of 
   the Python 3 code:

from google.ads.google_ads.client import GoogleAdsClient
credentials = {
    'developer_token': ... # received in (2)
    'login_customer_id': ... # the manager account ID
    'json_key_file_path': ... # where I saved the JSON key file from (6)
    impersonated_email': ... # the service account's email
}
client = GoogleAdsClient.load_from_dict(credentials)
ga_service = client.get_service('GoogleAdsService', version='v6')
response = ga_service.search(
    GA_CUSTOMER_ID,
    query='SELECT campaign.cost_micros FROM campaign'
)
for item in response:
    print(item)
(I really hope the code is formatted properly, sorry if it isn't)
The last two lines are for me to get a feeling of what I'm working with, 
while the rest should be definitive, unless there is a better way, of 
course.
Instead of getting the response, I get the error NOT_ADS_USER: "User in the 
cookie is not a valid Ads user."
I obviously did something wrong somewhere, but after three days I really 
don't know what else to try. The amount of options available is 
discouraging, and I have the sensation that sometimes the documentation 
contradicts itself on different pages, or maybe I just misunderstood 
something.

If anyone could give me some insight, I would be very grateful.
Thanks for having the patience to read this wall of text.

Best Regards
Davide

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/a24a5eb7-13d2-467d-85f3-93a139ea1e18n%40googlegroups.com.

Reply via email to