Hi Team,

I have Service account credentials for Google ads Manager account. I'm 
using below code for reporting purposes, instead of passing json key file 
path, there is any way to pass json object?


"""Initializes a AdManagerClient using a Service Account."""

from googleads import ad_manager
from googleads import oauth2

# OAuth2 credential information. In a real application, you'd probably be
# pulling these values from a credential storage.
KEY_FILE = 'INSERT_KEY_FILE_PATH'

# Ad Manager API information.
APPLICATION_NAME = 'INSERT_APPLICATION_NAME_HERE'


def main(key_file, application_name):
  oauth2_client = oauth2.GoogleServiceAccountClient(
      key_file, oauth2.GetAPIScope('ad_manager'))

  ad_manager_client = ad_manager.AdManagerClient(
      oauth2_client, application_name)
report_downloader = client.GetDataDownloader(version='v202305')
report_job = {
    'reportQuery': {
        'dimensions': [ 'ORDER_ID','LINE_ITEM_ID','LINE_ITEM_NAME'],
        'adUnitView': 'HIERARCHICAL',
        'dimensionAttributes': ['ORDER_START_DATE_TIME',
                                  'ORDER_END_DATE_TIME'],
        'columns': ['AD_SERVER_IMPRESSIONS', 'AD_SERVER_CLICKS',
                    'AD_SERVER_CTR'],
        'dateRangeType': 'CUSTOM_DATE',
        'startDate': start_date,
        'endDate': end_date
    }
}

try:
  # Run the report and wait for it to finish.
  report_job_id = report_downloader.WaitForReport(report_job)

except errors.AdManagerReportError as e:
  print('Failed to generate report. Error was: %s' % e)

# Change to your preferred export format.
export_format = 'CSV_DUMP'
report_file = tempfile.NamedTemporaryFile(prefix='cug',suffix='.csv.gz', 
delete=False)
use_gzip_compression = True
# Download report data.
report_downloader.DownloadReportToFile(report_job_id, export_format,
report_file)
report_file.close()


if __name__ == '__main__':
  main(KEY_FILE, APPLICATION_NAME)

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/709d5fc8-8149-4653-92cb-bc28857143a4n%40googlegroups.com.

Reply via email to