I am unable to access the Google Analytics API from rails. I keep getting insufficient permissions even though I have already set the service account.
I have created a service account:
After having the service account and have the secret JSON file and the email. Then I go to Google Analytics:
Once I have that, pretty much use the following code: https://gist.github.com/CoryFoy/9edf1e039e174c00c209e930a1720ce0 to get the reports.
But I keep getting forbidden: User does not have sufficient permissions for this profile
. Even when I try to get the access_token and use it in javascript:
gapi.analytics.auth.authorize({
serverAuth: {
access_token: 'accessToken'
}
});
I get:
error:{
code: 403
errors: [
{
domain: "global"
message: "User does not have sufficient permissions for this profile."
reason: "insufficientPermissions"
}
]
}
Am I missing something? This used to work and I never had a problem with it, but for some reason it stopped working. Any guidance will be appreciate it.
Thank you!
UPDATE
UA (Universal Analytics) will stop processing data on July 1st 2023. It means will stop support for it, so you will need to update to Analytics 4.
Articles by Google
This has something to do with how you create an analytics property. Since they remove the views from analytics 4, now you need to create a universal analytics property.
The code stays the same as this is an analytics change.
UPDATE
UA (Universal Analytics) will stop processing data on July 1st 2023. It means will stop support for it, so you will need to update to Analytics 4.
Articles by Google