I am having an issue where I am able to authenticate when running as a Console Application. But when I make it a Windows Service and install it, I am unable to authenticate. I have used log debug statements to isolate the issue.
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets {
ClientId = "myClientId",
ClientSecret = "myClientSecret"
},
new[] {
CalendarService.Scope.Calendar
},
"myProjectName",
CancellationToken.None,
new FileDataStore("myProjectName")
).Result;
The issue is with the above statement. This is surrounded by a try/catch, but no Exception is thrown. There is a log statement immediately after this, but it is never executed. My best guess is that the issue is with the FileDataStore. By default Google stores this is %AppData% which my program can find when I run it manually, but when it is a web service I am forced to give it an account type like Local System or Local Service I need to set it as User I think. My guess is that this prevents it from finding the file in %AppData%. Does anyone have any suggestions as to how to help the Windows Service find %AppData%? Or is a Windows Service a bad approach in this situation?
Thank you in advance for any help.