Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Daily Limit for Unauthenticated Use Exceeded Google Api Calendar

I'm testing a sample code. It has always worked but suddenly i get:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
 }
}

Again, it has ALWAYS worked. Nothing changed. I know to set console dev stuff and blablabla. I would like to know the cause of this issue.

This is my script:

  gapi.client.init({
        'apiKey': 'xxxxxxxx',

        'discoveryDocs': ["https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest"],
        'clientId': 'xxxx.apps.googleusercontent.com',
        'scope': 'https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar',
      }).then(function() {


            gapi.client.calendar.events.list({
              'calendarId': 'primary',
              'timeMin': (new Date()).toISOString(),
              'showDeleted': false,
              'singleEvents': true,
              'maxResults': 10,
              'orderBy': 'startTime' //from input
            }).then(function(response) {
             var events = response.result.items;

              if (events.length > 0) {
                for (var i = 0; i < events.length; i++) {
                  var event = events[i];
                  var when = event.start.dateTime;
                  if (!when) {
                    when = event.start.date;
                  }

                  appendPre(event.summary + ' (' + when + ')created at '+ event.created);



                }
              } else {
                appendPre('No upcoming events found.');
              }

            });


    });
function appendPre(message) {
        var pre = document.getElementById('content');
        var textContent = document.createTextNode(message + '\n');
        pre.appendChild(textContent);
      }
like image 483
Valerio Marzulli Avatar asked Mar 08 '23 23:03

Valerio Marzulli


2 Answers

Even if you are not authenticating to Calendar as a user, you should create a client project and attach your key to requests so that Google has a project to "bill" the quota usage against. This will prevent these kind of issues in the future. See Google's help article but the general steps would be:

1) Create a Google API Project at https://console.developers.google.com. 2) Enable Calendar API for the project. 3) Get the API key under API Manager > Credentials. 4) Include the key as a parameter for all your Calendar API requests. E.g.

GET https://www.googleapis.com/calendar/v3/calendars/calendarId/events?key={your_key}
like image 137
Jay Lee Avatar answered Apr 28 '23 05:04

Jay Lee


Solved with "https://www.googleapis.com/auth/calendar.readonly" scope! It works again without any changes. Maybe it needs some time, but "https://www.googleapis.com/auth/calendar" still not working.

like image 23
Valerio Marzulli Avatar answered Apr 28 '23 04:04

Valerio Marzulli