代码之家  ›  专栏  ›  技术社区  ›  confusedMind

如何与谷歌日历同步数据库

  •  0
  • confusedMind  · 技术社区  · 7 年前

    我正在使用这个代码,它工作,并允许我的应用程序获得 Calendar 从使用过的google帐户中列出。

    UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
    
    new ClientSecrets
    {
        ClientId = "xxx",
        ClientSecret = "xxxx-xxxx",
    },
                new[] { CalendarService.Scope.Calendar },
                "support@xxx.com",
                CancellationToken.None).Result;
    
    
    
        // Create the service.
        var service = new CalendarService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = "xxx",
        });
    
        CalendarListResource.ListRequest cal = service.CalendarList.List();
        cal.MaxResults = 10;
    
        var calresult = cal.Execute().Items;
    

    我的问题是,当我这样做时,我会将所有日历和事件导入本地数据库,因此一小时后,我需要运行一个脚本,用最新的日历和事件信息更新数据库,因为他们可能会添加新事件或删除一些与日历相同的事件。

    不知道在哪里可以找到任何建议?

    1 回复  |  直到 7 年前
        1
  •  0
  •   confusedMind    7 年前

    对于其他人:

    答案是:

    How to access users calendar list and events from google api using access token and refresh token

    基本上,您保存令牌,然后在日历中使用它。

    推荐文章