I use GoogleWebAuthorizationBroker.AuthorizeAsync () to authorize a user for GoogleDrive.
It works fine with the console or user interface, but it hangs if the method is executed in the context of the Windows service, even if I was authorized earlier in console mode, and the JSON data is stored in the provided FileDataStore file.
My code is as follows:
ClientSecrets secrets = new ClientSecrets { ClientId = CLIENT_ID, ClientSecret = CLIENT_SECRET };
FileDataStore store = new FileDataStore("MyFolder");
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
secrets,
new string[] {
DriveService.Scope.DriveFile,
DriveService.Scope.Drive,
"user",
CancellationToken.None,
store).Result;
Does this method not work at all in Windows Service, or am I missing something?
Is there an alternative way to authorize a user under Windows? (I'm not interested in ServiceAccountCredential for this case).
Thanks in advance.