GoogleWebAuthorizationBroker throwing System.ObjectDisposedException exception in Blazor .Net 5.0

Viewed 81

I'm trying to use the Google Calendar API in my Blazor server-side app.

I create the credentials following the instructions:

UserCredential credential;

using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read)) {
      string credPath = "token.json";
      credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
          GoogleClientSecrets.Load(stream).Secrets,
          Scopes,
          "user",
          CancellationToken.None,
          new FileDataStore(credPath, true)).Result;
}

When calling the Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker I get the following error thrown:

System.ObjectDisposedException: 'Safe handle has been closed. Object name: 'SafeHandle'.'

Is this to be expected? Can I simply ignore this error, or is there anything I should do about it?

0 Answers
Related