Search code examples
pythongoogle-analytics-api

What Oauth2 scope do I need to access Google Analytics Admin API?


I have an Oauth flow that gets the following scopes: email https://www.googleapis.com/auth/analytics https://www.googleapis.com/auth/analytics.readonly

However, when I query Google Analytics Admin API:

from google.analytics.admin import AnalyticsAdminServiceClient
client = AnalyticsAdminServiceClient(credentials=creds)
results = client.list_account_summaries()

I get the following error:

google.api_core.exceptions.PermissionDenied: 403 Request had insufficient authentication scopes. [reason: "ACCESS_TOKEN_SCOPE_INSUFFICIENT",...

I also tried adding: https://www.googleapis.com/auth/analytics.provision, but that didn't help. Using this site to try and find scopes: https://developers.google.com/identity/protocols/oauth2/scopes

Does anyone know which one is needed?


Solution

  • I found that you have to have the following scope.

    https://www.googleapis.com/auth/analytics.edit