I've been trying to authenticate to google ads API using my service account 
using the following code in python
import pandas as pd
from google.ads.googleads.client import GoogleAdsClient

def main():
    try:
        # Initialize the Google Ads API client with the service account key 
file
        client = GoogleAdsClient.load_from_storage("content-api-key.json")

        # Define a customer ID (your Google Ads account ID)
        customer_id = 'MY_CUSTOMER_ID'

        # Define a query to fetch campaign data (modify as needed)
        query = (
            f"SELECT campaign.id, campaign.name, metrics.impressions, 
metrics.clicks "
            f"FROM campaign "
            f"WHERE segments.date DURING LAST_7_DAYS "
            f"AND campaign.status = 'ENABLED'"
        )

        # Create a Google Ads service client
        ga_service = client.service.google_ads

        # Execute the query and fetch campaign data
        response = ga_service.search(
            customer_id=customer_id,
            query=query,
        )

        # Process and print the results (modify as needed)
        for row in response:
            print(
                f"Campaign ID: {row.campaign.id.value}, "
                f"Name: {row.campaign.name.value}, "
                f"Impressions: {row.metrics.impressions.value}, "
                f"Clicks: {row.metrics.clicks.value}"
            )

    except Exception as ex:
        print(f"An error occurred: {ex}")

if __name__ == "__main__":
    main()

i have got the service account key generated as a json file. I am getting 
the following error:
An error occurred: The client library configuration is missing the required 
"use_proto_plus" key. Please set this option to either "True" or "False". 

Now i am confused as service account doesnt need any configuration file so 
where do i add this "use_proto_plus" key and solve this problem. Any help 
would be appreciated.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/a418723c-6a08-43ca-9d51-4ecbdeb0b0c8n%40googlegroups.com.

Reply via email to