0

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.

1 Answer 1

1

Using this approach is only valid if you have a UI, because it will launch a browser to ask for authentication. For a service you have to ask for another kind of key that implies installing a certificate in the server. It is explained in OAuth2ServiceAccount.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.