goldylucks
goldylucks

Reputation: 6144

Google analytics API with a service account wrongfully Quota Error

tl;dr: I'm getting Quota Error: You have exceeded the maximum number of writes/day for this project even tho I have 50k queries / day as the quota limit.

I have a project on google cloud consle with GA API enabled:

enter image description here

Oddly enough, in the GA Quotas view I see two anonymous Query sections, both with 50k queries / day: (deleted the graphs to capture both quotas on same screen)

enter image description here

A side question here, why do I have two Query sections? what does each mean?

I have a service account with access to this project:

enter image description here

with a generated JSON key:

enter image description here

and I'm using that service account to make API requests:

const path = require('path')
const { google } = require('googleapis')

module.exports = createApiInstance

const keyFilePath = path.resolve(__dirname, '../../credentials.json')

const auth = new google.auth.GoogleAuth({
  keyFile: keyFilePath,
  scopes: ['https://www.googleapis.com/auth/analytics.edit'],
})

auth.getClient().then(client => {
  client.request(params)
})

I can get away with just a few requests in a day before I run into the quota limit error.

One weird thing is that even tho I just made some requests a few minutes ago, the service account's logs come up empty:

enter image description here

Which would be tempting to say the service account isn't being used, but, if that was the case how would I be able to get away with the few requests that do actually pass?

I'm not using any Auth'ing other than the service account generated credentials file 🤷‍♀️

As an aside, we are using the same service account with the same credentials file on another project for a different google API, and it works as expected.

any ideas what's going on here?

Upvotes: 2

Views: 467

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116958

First off do not go by what you are seeing in the google developer console.

  1. The report does not display write requests only total requests.
  2. Default write request quota is 50 not 50000
  3. that is not Realtime report
  4. its a estimate it is not 100% correct
  5. not all apis write to the service account logs.
  6. this is a project based quota so if you have any other methods writing then they are in the same total.

If the error message says you are going over the limit you are going over the limit. Just apply for an extension. This is one of the easer apis to get an extension on.

Limits and Quotas on API Requests enter image description here

You have to go over to https://console.cloud.google.com/ to see what your writes per day are

enter image description here

Upvotes: 2

Related Questions