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:
- Created a service account with View permission (https://console.cloud.google.com/).
- Analytics API is enabled.
- Service account added as a Viewer into GA4 property access settings.
- I'm using Nest.js back-end with the latest googleapis npm package. Here's the code:
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/datapackage for that.