Google Calendar fails on hosting server but works on localhost

0

This has been working just fine. A day a go I started to get the follow without any changes to the code on the production server. It still works on the localhost:

using (var stream =
               new FileStream(System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/GoogleCalendar/client_secret.json"), FileMode.Open, FileAccess.Read))
            {
                //string credPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                string credPath = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/");
                credPath = Path.Combine(credPath, ".credentials/calendar-dotnet-quickstart.json");
          
                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;
               // Console.WriteLine("Credential file saved to: " + credPath);
            }

I get the following error assigning credentials:

System.AggregateException: One or more errors occurred. ---> System.ComponentModel.Win32Exception: Application not found at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__6.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\LocalServerCodeReceiver.cs:line 86 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.d__8.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth\OAuth2\AuthorizationCodeInstalledApp.cs:line 77 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__4.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 134 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 60 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task`1.get_Result() at CFRA_MVC.Core.GoogleCalendar..ctor() ---> (Inner Exception #0) System.ComponentModel.Win32Exception (0x80004005): Application not found at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__6.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\LocalServerCodeReceiver.cs:line 86 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.d__8.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth\OAuth2\AuthorizationCodeInstalledApp.cs:line 77 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__4.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 134 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext() in C:\Apiary\v1_19\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 60<--- 
google-calendar-api
asked on Stack Overflow Apr 8, 2021 by ismirnov • edited Apr 8, 2021 by Carlos M

1 Answer

0

I have replaced the both json files and folders they were in and it seemed to fix it.

answered on Stack Overflow Apr 9, 2021 by ismirnov

User contributions licensed under CC BY-SA 3.0