4

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);
      }
Valerio Marzulli
  • 905
  • 1
  • 8
  • 13
  • Possible duplicate of [Keep getting a "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup" when attempting to google plus login on my web app](https://stackoverflow.com/questions/19335503/keep-getting-a-daily-limit-for-unauthenticated-use-exceeded-continued-use-requ) – Andrew Nolan May 29 '17 at 15:33
  • 2
    yeah i read a lot of response obviously, If I wrote the question is because I still have not solved it – Valerio Marzulli May 29 '17 at 15:38

2 Answers2

5

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}
Jay Lee
  • 13,415
  • 3
  • 28
  • 59
  • yeah i know how to do that. In fact, i can get all my events with "https://www.googleapis.com/auth/calendar.readonly" scope, but i need also to use "https://www.googleapis.com/auth/calendar" and when using it i get the error. I added api key. – Valerio Marzulli May 30 '17 at 07:32
  • These are all details you need to put in your question since we don't know if you're doing oauth, what scopes you are using and if you are sending a key. May be good to go back and add now for completeness sake. – Jay Lee May 30 '17 at 10:34
  • added my script to question – Valerio Marzulli May 30 '17 at 10:56
  • I ran into the same issue, and while it is likely true that if he was missing scope, he should add scope, but i was getting a similar error for a different API because i had not been instantiating with my API key despite having a token. – DevMike Aug 11 '18 at 05:07
2

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.

Valerio Marzulli
  • 905
  • 1
  • 8
  • 13
  • 1
    how did you do it? i'm using same for drive. readonly on public folder, and still getting an error. – aleXela Nov 02 '17 at 17:44