GoogleWebAuthorizationBroker无法在IIS主机

时间:2017-09-11 10:23:17

标签: c# asp.net

我使用以下代码使用Google .Net客户端库向Google进行身份验证 我使用这段代码:

using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
        {
            string credPath = HttpContext.Current.Request.MapPath("");
            string fileName = string.Format(".credentials/calendar-{0}", strLoginName);
            credPath = Path.Combine(credPath, fileName);
            credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets,
                Scopes,
                "user",
                CancellationToken.None,
                new FileDataStore(credPath, true)).Result;
        }

我正在使用自己的客户端ID和客户端密钥。当我从visual studio运行时,此代码完全正常工作,但在IIS中托管后无效。 它有例外

  

System.AggregateException:发生了一个或多个错误。 ---> System.NotSupportedException:无法启动带有“https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&response_type=code&client_id=100583113105-3duloq0e8j9o6aapc035grmvo9j2chtv.apps.googleusercontent.com&redirect_uri=http:%2F%2F127.0.0.1:61158%2Fauthorize%2F&scope=https:%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar”的浏览器进行授权。请参阅内部异常了解详细信---> System.ComponentModel.Win32Exception:拒绝访问      在System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)      在System.Diagnostics.Process.Start(ProcessStartInfo startInfo)      在Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__14.MoveNext()      ---内部异常堆栈跟踪结束---      在Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__14.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束---      在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()      在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)      在Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.d__8.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束---      在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()      在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)      在Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__4.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束---      在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()      在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)      在Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext()      ---内部异常堆栈跟踪结束---      在System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)      在DataHandler.GoogleCalendar.SyncCalendar(NameValueCollection参数)   ---> (内部异常#0)System.NotSupportedException:无法启动带有“https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&response_type=code&client_id=100583113105-3duloq0e8j9o6aapc035grmvo9j2chtv.apps.googleusercontent.com&redirect_uri=http:%2F%2F127.0.0.1:61158%2Fauthorize%2F&scope=https:%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar”的浏览器进行授权。请参阅内部异常了解详细信---> System.ComponentModel.Win32Exception:拒绝访问      在System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)      在System.Diagnostics.Process.Start(ProcessStartInfo startInfo)      在Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__14.MoveNext()      ---内部异常堆栈跟踪结束---      在Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__14.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束---      在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()      在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)      在Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.d__8.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束---      在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()      在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)      在Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__4.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束---      在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()      在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)      at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext()< ---

我该如何解决?

0 个答案:

没有答案