getredash/redash · error · Exception
Failed getting accounts.
Error message
Failed getting accounts.
What it means
During schema discovery (_get_tables), the runner calls the GA Management API accounts().list(); if the response has no 'items' key it raises 'Failed getting accounts.' — meaning the API returned an empty or unexpected payload, commonly because authentication lacks access to any account or the API is disabled.
Source
Thrown at redash/query_runner/google_analytics.py:131
def __init__(self, configuration):
super(GoogleAnalytics, self).__init__(configuration)
self.syntax = "json"
def _get_analytics_service(self):
scopes = ["https://www.googleapis.com/auth/analytics.readonly"]
try:
key = json_loads(b64decode(self.configuration["jsonKeyFile"]))
creds = Credentials.from_service_account_info(key, scopes=scopes)
except KeyError:
creds = google.auth.default(scopes=scopes)[0]
return build("analytics", "v3", credentials=creds)
def _get_tables(self, schema):
accounts = self._get_analytics_service().management().accounts().list().execute().get("items")
if accounts is None:
raise Exception("Failed getting accounts.")
else:
for account in accounts:
schema[account["name"]] = {"name": account["name"], "columns": []}
properties = (
self._get_analytics_service()
.management()
.webproperties()
.list(accountId=account["id"])
.execute()
.get("items", [])
)
for property_ in properties:
if "defaultProfileId" in property_ and "name" in property_:
schema[account["name"]]["columns"].append(
"{0} (ga:{1})".format(property_["name"], property_["defaultProfileId"])
)
return list(schema.values())View on GitHub (pinned to ca79fe988d)
Solutions
- Confirm the service account user (or OAuth user) has at least Reader access on a GA account and its email is invited in GA Admin
- Enable the Google Analytics API for the GCP project and use the correct credentials JSON
- Verify scopes include https://www.googleapis.com/auth/analytics.readonly
- Call the Management API directly (accounts().list()) with the same creds to see the raw response
Defensive patterns
Strategy: try-catch
Try / catch
try:
runner.get_schema(scope)
except Exception as e:
if "Failed getting accounts" in str(e):
alert_admin_to_check_ga_access_and_api_enablement() Prevention
- Grant the service account Reader access on a GA account before adding the data source
- Enable the Analytics API in the GCP project
- Verify credentials JSON and scopes (analytics.readonly) during setup
When it happens
Trigger: test_connection / schema load when the service account or OAuth user has no GA accounts, the Analytics API is not enabled for the project, or scopes are insufficient so list() returns an error dict without items.
Common situations: Missing google-analytics.readonly scope, Analytics API disabled in GCP console, service account email not added to any GA account, quota/project mixups.
Related errors
- Invalid JWT token
- Error during query execution. Reason: {error}
- Username and Password required
- Azure AD Client ID, Client Secret, and Tenant ID are require
- Failed to get schema: {str(e)}
AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28).
Data as JSON: /api/errors/0b0aa6d230024b33.
Report an issue: GitHub.