C# 谷歌日历API 403禁止创建事件

C# 谷歌日历API 403禁止创建事件,c#,asp.net-mvc-4,google-calendar-api,C#,Asp.net Mvc 4,Google Calendar Api,我被卡住了,谷歌的文档一点帮助都没有 我已使用适当的作用域对应用程序进行了身份验证。我获得同意屏幕,刷新令牌已正确存储 我可以在用户上查看日历,但当我尝试插入事件时,会出现403禁止错误 这是我用来添加事件的代码。(在我添加脱机访问之前,相同的代码正在工作) 有没有人能解释出问题所在?说403禁止域的错误并没有什么帮助 当然,我已经在Google控制台中启用了必要的API,并且作用域是正确的,因为我通过使用同意屏幕对用户进行身份验证来获得刷新令牌。显然,我使用了错误的EventAttendee.

我被卡住了,谷歌的文档一点帮助都没有

我已使用适当的作用域对应用程序进行了身份验证。我获得同意屏幕,刷新令牌已正确存储

我可以在用户上查看日历,但当我尝试插入事件时,会出现403禁止错误

这是我用来添加事件的代码。(在我添加脱机访问之前,相同的代码正在工作)

有没有人能解释出问题所在?说403禁止域的错误并没有什么帮助


当然,我已经在Google控制台中启用了必要的API,并且作用域是正确的,因为我通过使用同意屏幕对用户进行身份验证来获得刷新令牌。

显然,我使用了错误的
EventAttendee.Id
。这个Id是在我验证用户身份时提供的,所以我错误地认为它是应该提供的-我错了


有时候,你只需要把问题写下来,自己看看答案。

我面临着同样的问题,当我把auth response中的
googleId
作为
EventAttendee.id
时,我得到了403的回复。要发送的正确id是什么?
UserCredential credential = GetCredential(user.Username);

if (credential != null)
{
    CalendarService service = new CalendarService(new BaseClientService.Initializer()
    {
        HttpClientInitializer = credential,
        ApplicationName = "OO Software Service System",
    });

    //Create the event.
    Event e = new Event()
    {
        Attendees = new List<EventAttendee> 
        {
            new EventAttendee() 
            {
                Id = user.GoogleId, 
                Email = user.Username
            }
        },
        Start = new EventDateTime()
        {
            DateTime = start
        },
        End = new EventDateTime()
        {
            DateTime = end
        },
        Created = DateTime.Now,
        Summary = eventName
    };

    //Insert the event into the calendar.
    e = service.Events.Insert(e, "primary").Execute();
public static string[] GetScopes()
{
    return new string[] { CalendarService.Scope.Calendar, PlusService.Scope.PlusMe };
}

public static UserCredential GetCredential(string username)
{
    return GoogleWebAuthorizationBroker.AuthorizeAsync(
        GetSecrets(),
        GetScopes(),
        username,
        CancellationToken.None,
        new ServiceSystemDataStore()).Result;
}