googleworkspace / dotnet-samples

.NET samples for Google Workspace APIs
Apache License 2.0
167 stars 140 forks source link

Two Errors in GoogleWebAuthorizationBroker.AuthorizeAsync on Google Calendar .NET Example #26

Closed dotI0 closed 4 years ago

dotI0 commented 5 years ago

I have a Problem connecting my .NET C# Application with Google Calendar using the Google.Apis.Calendar.v3 NuGet Package.

If I use the Code provided by the .NET example given by Google, I get two errors. The example on the Google page: https://developers.google.com/calendar/quickstart/dotnet

The error occurred in the following code section after authenticating on the opened web page. credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result;

Error One:

InvalidOperationException: The character set provided in ContentType is invalid. Cannot read content as string using an invalid character set.

Error Two:

ArgumentException: '"UTF-8"' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.

Full Code: https://pastebin.com/1v7C3s66

The Application also creates a folder named token.json and not a token json file. Is this the problem?

What should I do?

dcaplopu commented 4 years ago

I have the same problem with the token.json file not created (only a directory). My code runs ok in Windows 7 but in Windows 10 the token.json file is not created. I don't know if the OS version is the problem here.

dotI0 commented 4 years ago

With an update of the Google API the error resolved.