簡體   English   中英

在 Google 日歷 Api c# 中插入活動時出現 403 錯誤

[英]403 error when inserting event with attendants in Google Calendar Api c#

在 .net 項目中,我正在嘗試使用谷歌日歷 v3 api 添加一個有一些服務員的活動。 我可以成功創建沒有服務員的活動,但是當我嘗試添加服務員時,它給了我以下錯誤:

Google.Apis.Requests.RequestError
Calendar usage limits exceeded. [403]
Errors [
    Message[Calendar usage limits exceeded.] Location[ - ] Reason[quotaExceeded] Domain[usageLimits]
]

我之前沒有完成任何請求(實際上,我已經創建了新的 gmail 帳戶並將他們各自的日歷與他們的 api 憑據鏈接),並且添加了超過 5 個事件。

這是創建事件的代碼

public class CalendarQuickstart
{
    private string jsonFile { get; set; }
    private string RutaCredentials { get; set; }
    private string calanderId { get; set; }

    public CalendarQuickstart()
    {
        RutaCredentials = WebConfigurationManager.AppSettings["rutaCredentials"];
        jsonFile= "credentials.json";
        calanderId = "9cp270uok8t0tq2uss3qb54dos@group.calendar.google.com";
    }

    static List<Event> DB = 
         new List<Event>() {
            new Event(){
                Id = "eventid" + 3,
                Summary = "Google I/O 2015",
                Location = "800 Howard St., San Francisco, CA 94103",
                Description = "A chance to hear more about Google's developer products.",
                Start = new EventDateTime()
                {
                    DateTime = new DateTime(2019, 09, 29, 15, 30, 0),
                    TimeZone = "America/Los_Angeles",
                },
                End = new EventDateTime()
                {
                    DateTime = new DateTime(2019, 09, 30, 15, 30, 0),
                    TimeZone = "America/Los_Angeles",
                }
                ,
                  Recurrence = new String[] {
                      "RRULE:FREQ=WEEKLY;BYDAY=MO"
                  }
                 ,
                Attendees = new EventAttendee[] {

                    new EventAttendee() { Email = "gustavooguedareyes@gmail.com"}
                }
            }
         };



    public async Task crear_evento()
    {

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

        ServiceAccountCredential credential;

        string filePath = System.Web.Hosting.HostingEnvironment.MapPath(RutaCredentials + jsonFile);

        using (var stream =
            new FileStream(filePath, FileMode.Open, FileAccess.Read))
        {
            var confg = Google.Apis.Json.NewtonsoftJsonSerializer.Instance.Deserialize<JsonCredentialParameters>(stream);
            credential = new ServiceAccountCredential(
               new ServiceAccountCredential.Initializer(confg.ClientEmail)
               {
                   Scopes = Scopes
               }.FromPrivateKey(confg.PrivateKey));
        }

        var service = new CalendarService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = "Calendar API Sample",
        });


        var myevent = DB.Find(x => x.Id == "eventid" + 3);

        var InsertRequest = service.Events.Insert(myevent, calanderId);

        try
        {
            InsertRequest.Execute();
        }
        catch (Exception e)
        {
            try
            {
                service.Events.Update(myevent, calanderId, myevent.Id).Execute();
                Console.WriteLine("Insert/Update new Event ");
                Console.WriteLine(e.ToString());
                Console.Read();

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.WriteLine("can't Insert/Update new Event ");

            }
        }



    }
}

提供以下解決方案和參考:

Calendar usage limits exceeded可能原因有很多

在您的情況下,可能的原因是您添加了外部(不是來自您的域)活動參與者。

為了防止垃圾郵件,似乎有以下限制:

免費 Google Apps 帳戶對於用戶:1 位外部訪客 40 分鍾

此外,目前很多人都遇到了類似的問題,並且已經在 Public Issue tracker 上針對此問題提交了錯誤報告

如果您確定您沒有超出任何配額限制,則現有錯誤可能是您的問題的原因。 在這種情況下,我建議你給這個 bug 報告一個“星”,以增加它的可見性,並希望它會盡快修復。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM