im trying to use get functions for reports under googleads.
#My code
from googleads import adwords from googleads import errors import time import datetime import os import sys if __name__ == '__main__': ## initialize google adwords client object adwords_client = adwords.AdWordsClient.LoadFromStorage("googleAds.yaml") ## set your customer-ID adwords_client.SetClientCustomerId('389204095687-xx.apps.googleusercontent.com') report_downloader = adwords_client.GetReportDownloader(version='v9') ## get CLICK_PERFORMANCE report for yesterday as an example report_date = datetime.datetime.now()-datetime.timedelta(days=1) report_date_string = report_date.strftime("%Y%m%d") ## build the report query report_query = (adwords.ReportQueryBuilder() .Select('campaign.id','ad_group.id', 'metrics.impressions', 'metrics.clicks') .From('ad_group') .During(start_date=report_date_string,end_date=report_date_string) .Build()) ## download the report as CSV into string csv_report = report_downloader.DownloadReportWithAwql( report_query, 'CSV', skip_report_header=True, skip_column_header=True, skip_report_summary=True, include_zero_impressions=False)
But i receive the below traceback error-
with open(path, 'rb') as handle: FileNotFoundError: [Errno 2] No such file or directory: 'googleAds.yaml' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<ipython-input-5-d90ad0259074>", line 16, in <module> adwords_client = adwords.AdWordsClient.LoadFromStorage("googleAds.yaml") File "C:\Users\jj\AppData\Local\Continuum\anaconda3\lib\site-packages\googleads\adwords.py", line 193, in LoadFromStorage cls._OPTIONAL_INIT_VALUES)) File "C:\Users\jj\AppData\Local\Continuum\anaconda3\lib\site-packages\googleads\common.py", line 247, in LoadFromStorage 'Given yaml file, %s, could not be opened.' % path) GoogleAdsValueError: Given yaml file, googleAds.yaml, could not be opened.
I reviewed the documentation for Oath: https://github.com/googleads/googleads-python-lib/wiki/API-access-using-own-credentials-(installed-application-flow)#step-2---setting-up-the-client-library
but I already have all the credentials, i just dont know how to create the yml file and save it where python can detect it