Skip to content

'Credentials' object has no attribute 'universe_domain' in package google-analytics-data:  #12254

@chewei888

Description

@chewei888

I am experiencing an error with a Python script that has been working well since 2023. The script's main function is to extract sessions from Google Analytics 4 via the package google-analytics-data. However, after 7:30 AM PST on February 1, 2024, I received an error message stating that the 'Credentials' object has no attribute 'universe_domain'. 'universe_domain' is one of the attributes in the API key JSON file.

My script followed the guidance provided by Google in this link https://developers.google.com/analytics/devguides/reporting/data/v1/quickstart-client-libraries (I copied the example Python codes below), and I also referred to this article https://automation-help.com/google-analytics-data-api-ga4-with-python-extensive-guide/. I can confirm that my API key is not expired and is working correctly. My service account is also enabled and running, with the proper permission in the GA property access management.

I believe the issue is with the Python package google-analytics-data itself, and I am wondering if anyone else has encountered a similar issue or has found a root cause or solution. Could someone please provide me with some information?

​from google.analytics.data_v1beta import BetaAnalyticsDataClient from google.analytics.data_v1beta.types import ( DateRange, Dimension, Metric, RunReportRequest, ) def sample_run_report(property_id="YOUR-GA4-PROPERTY-ID"): """Runs a simple report on a Google Analytics 4 property.""" # TODO(developer): Uncomment this variable and replace with your # Google Analytics 4 property ID before running the sample. # property_id = "YOUR-GA4-PROPERTY-ID" # Using a default constructor instructs the client to use the credentials # specified in GOOGLE_APPLICATION_CREDENTIALS environment variable. client = BetaAnalyticsDataClient() request = RunReportRequest( property=f"properties/{property_id}", dimensions=[Dimension(name="city")], metrics=[Metric(name="activeUsers")], date_ranges=[DateRange(start_date="2020-03-31", end_date="today")], ) response = client.run_report(request) print("Report result:") for row in response.rows: print(row.dimension_values[0].value, row.metric_values[0].value) 

Metadata

Metadata

Assignees

Labels

priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions