简体   繁体   English

超出 Google Calendar Api v3 配额

[英]Google Calendar Api v3 quota exceeded

I'm having a problem with creating calendar events ( With a google service account ), I have the Domain-wide Delegation enabled.我在创建日历事件(使用 google 服务帐户)时遇到问题,我启用了域范围委派。

The error i'm getting is: "Message[Calendar usage limits exceeded.] Location[ - ] Reason[quotaExceeded] Domain[usageLimits]"我得到的错误是:“消息[超出日历使用限制。]位置[-]原因[quotaExceeded]域[usageLimits]”

I've checked the usage and its below 10 requests ( The quota is set to 1,000,000 )我检查了使用情况及其以下 10 个请求(配额设置为 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?以前有人遇到过这个问题吗?

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.在服务帐户详细信息中,单击显示域范围委派,然后确保选中启用 G Suite 域范围委派复选框。
  3. If you haven't yet configured your app's OAuth consent screen, you must do so before you can enable domain-wide delegation.如果您尚未配置应用的 OAuth 同意屏幕,则必须先配置,然后才能启用域范围委派。 Follow the on-screen instructions to configure the OAuth consent screen, then repeat the above steps and re-check the checkbox.按照屏幕上的说明配置 OAuth 同意屏幕,然后重复上述步骤并重新选中复选框。
  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.单击查看客户端 ID,获取并记录客户端 ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM