Issue with Google Ads API - TypeError: expected str, bytes or os.PathLike object, not dict

212 views
Skip to first unread message

Daniel Aduayom Messan

unread,
Aug 5, 2024, 4:54:07 PM8/5/24
to Google Ads API and AdWords API Forum

Hello,

I hope this message finds you well. I'm writing to seek assistance with an issue I am encountering while using the Google Ads API in Python.

Context

I am working on a project that involves retrieving data from the Google Ads API. My application is supposed to authenticate using credentials stored in a dictionary and then fetch data for a specific client.

Problem

When I attempt to execute my code, I receive the following error message:

python
Copy code
TypeError: expected str, bytes or os.PathLike object, not dict

This error seems to indicate that a method in my code expects a file path rather than a dictionary.

Error Details

The error occurs when I try to load client configuration using the load_from_storage method of the GoogleAdsClient class. I passed a dictionary containing my API credentials to this method, which seems to be the source of the problem. The traceback indicates the issue is with a function expecting a string or file path type, but it's receiving a dictionary instead.

Steps Taken
  • I have checked the official documentation and examples but could not find a clear explanation for this error.
  • I tried replacing the dictionary with a YAML file path to see if that would resolve the issue, but it did not.
Request

Could you please provide guidance on how to correctly load credentials and resolve this TypeError? Any suggestions on the correct method to use for loading credentials would be greatly appreciated.

Thank you for your time and assistance.

Best regards,

Daniel

Reply all
Reply to author
Forward
0 new messages