问题
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