GMail Atom Feed - Webhook problem

Is anyone aware of some rate limiting or IP blocking that has occurred at Google from Particle’s VA servers (Ashburn, VA, USA)?

I can easily get the atom feed from my browser:

https://<username>:<password>@mail.google.com/mail/feed/atom/

but I get this when I test:

and:

this all worked before

Hi @BulldogLowell,

Hmm, so a 401 usually means bad credentials, and would be an error coming from Google.

Google is really often aggressive about rate limiting, that thread mentions:

 the documentation from google says only 1x access per 10 min ? 
 is it really that strict now ? anyone have any experience with this ?

Maybe just try waiting ~15 minutes or so between requests? The current webhook system will retry requests if they get an error, so it’s possible that’s aggravating the rate limits more.

I checked on our end and I don’t see any unusual rate limiting of requests to Google as far as I know, and those wouldn’t manifest as http error status codes from us. I’m happy to reach out to Google as well if waiting a little longer doesn’t fix it.

Thanks,
David

1 Like

@Dave

Thanks for the help here Dave!

2 Likes

Thanks Dave, I’m going to try to shut it down for a couple of days and see what happens, along with further limiting my calls.,

I’ll let you know if it restores or not.

Thanks!

1 Like

@KyleG / @Dave

So. I was able to find a very easy alternative method to gmail atom feed. I found this tutorial on google script and decided to use it…

Basically, it provides you with a URL that will return the data in the format you request, so I simply altered it to return a JSON:

/*    Gmail Counter by Amit Agarwal   */
/*    Published on 06/17/2013         */

function doGet() {
  
  var cache = CacheService.getPublicCache();
  var counter = cache.get("gmail-counter");
  
  // Cache the counter to stay within the Apps Script quota
  if (!counter) {
    counter = GmailApp.getInboxUnreadCount();
    // Cache the counter value for 20 minutes
    cache.put("gmail-counter", counter, 1200); 
  }
  
  // You can customize the output message
  counter = "{\"unread\":" + counter + "}"  //<<<<<< this bit
    
  // Output the result in plain text format
  return ContentService.createTextOutput(counter)
    .setMimeType(ContentService.MimeType.TEXT);
  
}

then created a new webhook with the URL that Google provided:

{
    "event": "gmail_count",
    "url": "https://script.google.com/macros/s/Xr7wodJdGwRaLW9eNGE6V-nBX_XhRr3z5d3y0G_3d7dl3e03qteT7pmz/exec",
    "requestType": "GET",
	"headers": null,
	"query": null,
	"responseTemplate": "{{unread}}",
	"responseTopic": "{{PARTICLE_DEVICE_ID}}_gmail_count",
	"json": null,
	"auth": null,
	"coreid": null,
	"deviceid": null,
	"mydevices": true
}

and it returns rather a rather pretty little number

Look Mom, no parsing!!!

void gotGmailFeed(const char *event, const char *data)
{
  emailCount = atoi(data);
}

My word clock is happy again!

4 Likes

That’s great to hear!!

Glad you got it working! Sorry I wasn’t more help!

Thanks,
David

2 Likes

Thats nice. but unfortunately I don’t get the webhook running as you showed here. After configuring the google script it tells me the correct number of unread emails if I use the generated URL.
But after creating the webhook, all I see is an empty data field


Any idea why?

Thanks in advance…

Ok after reading the instruction again carefully its working now fine (especially after setting the script rights to “Anyone, even anonymous” instead of just “Anyone”).