【问题标题】:Google Calendar Api v3 quota exceeded超出 Google Calendar Api v3 配额
【发布时间】:2020-03-07 16:29:13
【问题描述】:

我在创建日历事件时遇到问题(使用 google 服务帐户),我启用了域范围委派。

我得到的错误是: "消息[超出日历使用限制。] 位置[-] 原因[quotaExceeded] 域[usageLimits]"

我检查了使用情况及其以下 10 个请求(配额设置为 1,000,000)

这是我的代码:

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();

如果我尝试在没有参与者的情况下执行代码,它运行时不会出现任何错误。

以前有人遇到过这个问题吗?

【问题讨论】:

标签: c# asp.net-core google-calendar-api


【解决方案1】:

这是一个已知的错误

已在Issue tracker 上报告。您可以单击问题编号旁边的星号,以给予错误更高的优先级并接收更新。


但是,这有当前的解决方法(除了不包括与会者):

域范围委派模拟用户

你可以阅读如何做到这一点here,步骤是:

  1. 在表中找到新创建的服务帐户。在下面 操作,点击显示更多,然后点击编辑。
  2. 在服务帐户详细信息中,单击显示域范围委派, 然后确保启用 G Suite 域范围委派复选框是 检查。
  3. 如果您尚未配置应用的 OAuth 同意屏幕,您可以 必须这样做才能启用域范围委派。跟着 屏幕上的说明来配置 OAuth 同意屏幕,然后 重复上述步骤并重新勾选复选框。
  4. 点击保存更新服务账号,返回表 服务帐户。可以看到一个新列,域范围的委派。 点击查看客户 ID,获取并记下客户 ID。

【讨论】:

    猜你喜欢
    • 2012-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-05
    • 2019-06-10
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    相关资源
    最近更新 更多