I'm trying to access Google Analytics v4 API using Python and got this error:
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://analyticsreporting.googleapis.com/v4/reports:batchGet?alt=json returned "User does not have sufficient permissions for this profile.". Details: "User does not have sufficient permissions for this profile.">
I am using a Service Account
How I created the service account?
Analytics Reporting API
, Google Analytics Admin API
, Google Analytics Data API
and Google Analytics API
.Credentials
and created a new service account.Domain-wide Delegation
.How I tried to fix it so far?
Google's API says that the service do initialize, but cannot get data - get 403.
I've read all questions and answer in Stackoverflow, but yet couldn't find a sufficient solution that solves this problem.
After posting the question, I kept looking and searching the web and I found out that most of the questions and tutorials are not up-to-date because Google is constantly updating the API's. I found out that this documentation is referring to Universal Analytics v4 (which is deprecated and no logger supported).
So if you want to make requests to Google Analytics API, and you are using GA4 (which probably you do), you should enable Google Analytics Data API (GA4) in Google Cloud Console and follow this documentation.
After doing that I was able to access the API and get the data I was looking for.
Good luck everyone!