I'm trying to do a very dumb and obvious thing - set up a page on my website that shows the 10 most visited blog posts for the last 30 days. I want to use GA4 data for this. This is what I did:
const auth = new google.auth.GoogleAuth({
keyFile: '/home/...service-account.json',
scopes: ['https://www.googleapis.com/auth/analytics.readonly']
})
I get User does not have sufficient permissions for this profile.
error.
What do I do wrong, what have I missed?
Data API has to be enabled and used to access GA4 reporting. There's @google-analytics/data
package for that.