Google Ads API error accesing with service account
Hi I'm trying to connect an python script with google ads api.
I have: Ads Account manager with developer_token and the the account level is in "Test Account" Google ads api -> enabled.
service account added to the api and with file service.json and email like service_acc@project.iam.gserviceaccount.com
google-ads.yaml with
json_key_file_path: 'service.json' impersonated_email: 'service_acc@project.iam.gserviceaccount.com' use_proto_plus: True developer_token: 'developer_token'
client_ads_id (supuse to be in ads.google.com in help -> customer Id) 10 digits without
I can access client api with client = googleads.client.GoogleAdsClient.load_from_storage() with no error.
Then I try to create a user list with
user_list_service_client = client.get_service("UserListService") user_list_operation = client.get_type("UserListOperation") user_list = user_list_operation.create user_list.name = list_name user_list.description = description user_list.crm_based_user_list.upload_key_type = ( client.enums.CustomerMatchUploadKeyTypeEnum.CONTACT_INFO ) user_list.membership_life_span = 365 response = user_list_service_client.mutate_user_lists( customer_id=customer_id, operations=[user_list_operation] )
In the last line I get an error:
errors { error_code { authentication_error: NOT_ADS_USER } message: "User in the cookie is not a valid Ads user." }
and in the middle of the exception I got
status = StatusCode.UNAUTHENTICATED
I don't know how to link the client ads account with the api service account.
I've try to:
- The service account is not linked to the ads client. (I've invited to service_acc@project.iam.gserviceaccount.com but... obviously it doesn't arrive and doesn't accept the invitation automatically)
- In this doc talk about impersonate, and don't know how to do it
A Google Ads user with permissions on the Google Ads account you want to access. Google Ads does not support using service accounts without impersonation