Google Calendar Api v3 quota exceeded

牧云@^-^@ 提交于 2021-02-11 16:59:47

问题


I'm having a problem with creating calendar events ( With a google service account ), I have the Domain-wide Delegation enabled.

The error i'm getting is: "Message[Calendar usage limits exceeded.] Location[ - ] Reason[quotaExceeded] Domain[usageLimits]"

I've checked the usage and its below 10 requests ( The quota is set to 1,000,000 )

This is my code:

string[] Scopes = { CalendarService.Scope.Calendar, CalendarService.Scope.CalendarEvents };

using (var stream = new FileStream("cred.json", FileMode.Open, FileAccess.Read))
{
    GoogleCredential credential = GoogleCredential.FromStream(stream)
                                 .CreateScoped(Scopes);
    var service = new CalendarService(new BaseClientService.Initializer()
    {
        HttpClientInitializer = credential,
        ApplicationName = "TEST",
    });

    var ev = new Event();
    EventDateTime start = new EventDateTime();
    start.DateTime = DateTime.Now.AddMinutes(30);

    EventDateTime end = new EventDateTime();
    end.DateTime = DateTime.Now.AddMinutes(60);
    ev.Start = start;
    ev.End = end;
    ev.Summary = "Test";
    ev.Description = "Please Work";
    ev.Attendees = new List<EventAttendee>
    {
        new EventAttendee() { Email = "TestMail@gmail.com" }
    };

    var calendarId = "primary";
    service.Events.Insert(ev, calendarId).Execute();

If i try to execute the code without attendees it runs with out any error.

Did anyone encounter this problem before?


回答1:


This is a know bug

It has been reported on Issue tracker. You can click on the star next to the issue number to give more priority to the bug and to receive updates.


However, this has the current workaround (aside from not including attendees):

Domain-Wide Delegation or impersonate a user

You can read about how to do it here, the steps are:

  1. Locate the newly-created service account in the table. Under Actions, click show more, then Edit.
  2. In the service account details, click Show domain-wide delegation, then ensure the Enable G Suite Domain-wide Delegation checkbox is checked.
  3. If you haven't yet configured your app's OAuth consent screen, you must do so before you can enable domain-wide delegation. Follow the on-screen instructions to configure the OAuth consent screen, then repeat the above steps and re-check the checkbox.
  4. Click Save to update the service account, and return to the table of service accounts. A new column, Domain-wide delegation, can be seen. Click View Client ID, to obtain and make a note of the client ID.


来源:https://stackoverflow.com/questions/60579738/google-calendar-api-v3-quota-exceeded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!