0

I used the google Python example to connect to google analytics and collect all data. I was able to connect and collect data when I use this example, but when I change the profile_id to select a different view, I got the following error:

was:

profile_id = get_first_profile_id(service)

now:

profile_id = '68444917

googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A168847831&start-date=2018-01-01&end-date=2019-02-01&metrics=ga%3Asessions%2Cga%3AtotalEvents%2Cga%3Ausers&dimensions=ga%3AeventAction%2Cga%3Adate%2Cga%3AcontentGroup2%2Cga%3AcontentGroup3&filters=ga%3AeventAction%3D%3DDealer+site&samplingLevel=HIGHER_PRECISION&include-empty-rows=true&start-index=1&max-results=10000&alt=json returned "User does not have sufficient permissions for this profile.">

The admin checked my permission based on questions 1 and 2 and it looks I have access to all views.

YNR
  • 867
  • 2
  • 13
  • 28
  • Now that you have the API working call the [Account Summaries list](https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accountSummaries/list) endpoint and verify the API authorized user does, in fact, have API access to the desired view. – Matt Feb 12 '19 at 14:58
  • 1
    Good point. The 'Account Summaries list endpoint' just shows one view; the view that I was able to connect. – YNR Feb 12 '19 at 15:13
  • That tells me that whatever user you used to authenticate the API only has access to that one View. You could try to re-authorize as the intended user or add the current API user to the desired view. – Matt Feb 12 '19 at 15:30

1 Answers1

0

It is needed the permission granted to the created email account by google analytics as mentioned here:

The newly created service account will have an email address that looks similar to:

quickstart@PROJECT-ID.iam.gserviceaccount.com
Use this email address to add a user to the Google analytics view you want to access via the API. For this tutorial only Read & Analyze permissions are needed.
YNR
  • 867
  • 2
  • 13
  • 28