Connecting to Google Ads through Python with service account without .json file

26 views
Skip to first unread message

Mats Beckman

unread,
Aug 1, 2025, 12:22:06 PMAug 1
to Google Ads API and AdWords API Forum
Hello,

I am trying to connect to our Google Ads API through Python. I've gotten it to work with the load_from_storage and pointing to a .yaml file which also points to the service account .json file. 

This has tremendous security concerns, and it cannot be the only way to connect with a service account. Using load_from_dict seems to need JSON_KEY_FILE_PATH as a variable anyway, and the same goes for load_from_env. 

Surely there has to be a possibility to use variables instead, so that we do not store the keys in our repository? In the future we'll look at key vaults instead, and then we also just want to store the keys. 

The error message I get: 
Google Ads API call failed: Your YAML file is incorrectly configured for OAuth2. You need to define credentials for either the OAuth2 installed application flow (('client_id', 'client_secret', 'refresh_token')) or service account flow (('json_key_file_path',)).


Google Ads API Forum Advisor

unread,
Aug 1, 2025, 4:08:23 PMAug 1
to adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

From the provided information, I understand that the issue appears to be specific to the client library rather than the Google Ads API itself. For the Python Client library issues, I would suggest reaching out to the client library owner via this Google Ads Python Github issue tracker as they should be more equipped to provide guidance on this matter.

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-08-01 20:07:34Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01sxmDT:ref" (ADR-00324425)



Reply all
Reply to author
Forward
0 new messages