Google API 1.8.1 - GoogleWebAuthorizationBroker.AuthorizeAsync freezes under Windows

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.

+4
1

: . "" . " " ​​ " ".

, - .

+1

Source: https://habr.com/ru/post/1538681/


All Articles