nathanVegetable
nathanVegetable

Reputation: 79

GMail API user rate-limited over extended period of time

I am trying to do a simple call to get the email address of an account:

gmail().users().getProfile("me").execute().getEmailAddress();

However it always returns a user-rate-limited response:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 429 unknown
{
  "code" : 429,
  "errors" : [ {
    "domain" : "usageLimits",
    "message" : "User-rate limit exceeded.  Retry after 2019-09-18T18:49:00.748Z",
    "reason" : "rateLimitExceeded"
  } ],
  "message" : "User-rate limit exceeded.  Retry after 2019-09-18T18:49:00.748Z"
}

Regardless of waiting after the time mentioned, it always is returning this response. I had it retry for once an hour for the past 14 hours and it is still giving this response. I have checked my API quota and confirmed there is no other usage of the user for GMail in the timeframe.

I do have exponential backoff implemented, however due to an internal issue on my script yesterday there were many requests in a short period of time to the GMail API. As expected it hit the rate limit, but it appears that the rate limitation has not "turned off" since. Is this user-account blacklisted? How can I get the account up and running again?

Upvotes: 1

Views: 2406

Answers (2)

ziganotschka
ziganotschka

Reputation: 26796

According to Gmail API documentation:

Mail Sending Limits The Gmail API enforces the standard daily mail sending limits.

If these limits are exceeded a HTTP 429 Too Many Requests "User-rate limit exceeded" error mentioning "(Mail sending)" is returned with a time to retry.

The email sending limits

are applied over a rolling 24-hour period.

This explains why you needed to wait 24 hours since the original issue.

Have a look at the email sending limits, so you know which quota you exceeded and need avoid it in the future.

Upvotes: 2

nathanVegetable
nathanVegetable

Reputation: 79

Maybe the answer is patience, or maybe it's luck. But now after roughly 24 hours since the original issue with the requests my account appears to be working again.

Upvotes: 0

Related Questions