C#: How to use Google Calendar API in a Windows service

≯℡__Kan透↙ 提交于 2019-12-11 09:14:56

问题


I'm trying to build an application for retrieving calendar events from Google Apps Calendar.

I followed the steps on the following page which worked to a certain extend. https://developers.google.com/google-apps/calendar/quickstart/dotnet

The problem is, that this code doesn't work, when the application runs as a Windows service. The problem seems to be, that the code runs asynchronous and uses UserCredential. The application only works, if it is being run as a user.

Even if I manually run the application first in order to authenticate, it still doesn't work as a service.

I read somewhere, that I might be able to use ServiceAccountCredential and a public API access key. Because I have to synchronize every account (calendar) in the organization (Google Apps), this doesn't work at all. This can be done using the quickstart example, but just not as a service.

I need to be able to uthorize/synchronize using any Google Apps account, not just the one I used to create the app.

来源:https://stackoverflow.com/questions/31913183/c-how-to-use-google-calendar-api-in-a-windows-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!