【问题标题】:403 when trying to clear calendar using Google Calendar API v3?尝试使用 Google Calendar API v3 清除日历时出现 403?
【发布时间】:2014-10-27 20:26:07
【问题描述】:

我正在通过 .NET 客户端库使用 Google 日历 API v3 来构建已安装的应用程序。在我的开发者控制台中,我有一个使用日历 API 定义的项目。我可以添加事件,但无法清除日历。以下代码适用于创建项目的帐户,但不适用于任何其他帐户(返回 403 禁止):

UserCredential credential;
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
    new ClientSecrets
    {
        ClientId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
        ClientSecret = "yyyyyyyyyyyyyyyyyyy"
    },
    new[] { CalendarService.Scope.Calendar },
    "johndoe@gmail.com",
    CancellationToken.None,
    new FileDataStore("Somefolder"));

// Create the service
cs = new CalendarService(new BaseClientService.Initializer()
{
    HttpClientInitializer = credential,
    ApplicationName = "Calendar App",
});

cs.Calendars.Clear("primary").Execute(); // 403 returned here

如何更正此问题,以便能够清除用户的主日历?我看到other posts 谈论让用户共享他们的日历,但这并不实际,而且他们已经授予我的应用日历 API 权限。

【问题讨论】:

标签: google-api google-oauth google-api-dotnet-client google-authentication


【解决方案1】:

原来问题不在于上面的代码或我的项目设置。这是我测试过的一个帐户特有的问题。即使尝试通过 Web 界面“删除日历中的所有事件”也会导致此特定帐户出现同样的错误。在其他几个帐户上进行了测试,它们工作正常。从周围搜索来看,这似乎是人们可能遇到的并不少见的问题。我错误地将其归因于代码,但这是该帐户特有的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-11
    • 1970-01-01
    • 1970-01-01
    • 2020-10-11
    相关资源
    最近更新 更多