首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Google在Visual中运行,但在部署到IIS时挂起

Google在Visual中运行,但在部署到IIS时挂起
EN

Stack Overflow用户
提问于 2017-03-28 08:11:00
回答 1查看 1.6K关注 0票数 0

我正在和谷歌.Net客户端库合作。它的工作方式是当用户想要对Google进行身份验证时,库会生成一个新的网页供用户进行身份验证。

代码语言:javascript
运行
复制
System.Diagnostics.Process.Start(authorizationUrl);

我的代码使用了库

代码语言:javascript
运行
复制
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
    GoogleClientSecrets.Load(stream).Secrets,
    scopes,
    userName,
    CancellationToken.None).Result;

如果我通过Visual在本地运行这个程序,它可以正常工作。但是,如果我试图部署它,它就会挂起。如果使用使用本地IIS的运行它。我得到以下错误。

System.Exception: CreateServiceAccountAnalyticsReportingFailed -> System.AggregateException:发生了一个或多个错误。-> System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo -> System.ComponentModel.Win32Exception:在C:\Apiary\v1.22\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\LocalServerCodeReceiver.cs:line 89中的Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__6.MoveNext() )拒绝访问(在C:\Apiary\v1.22\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\LocalServerCodeReceiver.cs:line startInfo) )--从抛出异常的前一个位置开始的堆栈跟踪--在系统上。( .Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task任务) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task任务)在C:\Apiary\v1.22\google-api-dotnet-client\Src\Support\GoogleApis.Auth\OAuth2\AuthorizationCodeInstalledApp.cs:line 77中的Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.d__8.MoveNext() --从抛出异常的前一个位置开始的堆栈跟踪的结束--在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task任务中)(在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task任务中)在C:\Apiary\v1.22\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 134中的Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__4.MoveNext() --从以前在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification抛出异常的位置开始的堆栈跟踪的结束(任务)在Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext() in C:\Apiary\v1.22\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 60)在C:\Users\daimto\ 2015\Projects\WebApplication1\WebApplication1\index.aspx.cs:line \Visual 2015\Projects\WebApplication1\WebApplication1\index.aspx.cs:line 69 -内部异常堆栈跟踪C:\ EventArgs \daimto\EventArgs\Visual 31 C:\inetpub\wwwroot\App_Data\MyGoogleStorage中的EventArgs e)

我不是一个系统管理员类型的人,我对IIS了解很少。我的猜测是IIS没有权限来生成进程?这只是猜测而已。我尝试过将应用程序池设置为使用我自己的个人帐户,我也尝试过网络系统。

指向客户端库中的下列问题的链接

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-18 13:34:37

该库支持另一种用于Web应用程序的身份验证方法。

代码语言:javascript
运行
复制
using System;
using System.Web.Mvc;

using Google.Apis.Auth.OAuth2;
using Google.Apis.Auth.OAuth2.Flows;
using Google.Apis.Auth.OAuth2.Mvc;
using Google.Apis.Drive.v2;
using Google.Apis.Util.Store;

namespace Google.Apis.Sample.MVC4
{
    public class AppFlowMetadata : FlowMetadata
    {
        private static readonly IAuthorizationCodeFlow flow =
            new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
                {
                    ClientSecrets = new ClientSecrets
                    {
                        ClientId = "PUT_CLIENT_ID_HERE",
                        ClientSecret = "PUT_CLIENT_SECRET_HERE"
                    },
                    Scopes = new[] { DriveService.Scope.Drive },
                    DataStore = new FileDataStore("Drive.Api.Auth.Store")
                });

        public override string GetUserId(Controller controller)
        {
            // In this sample we use the session to store the user identifiers.
            // That's not the best practice, because you should have a logic to identify
            // a user. You might want to use "OpenID Connect".
            // You can read more about the protocol in the following link:
            // https://developers.google.com/accounts/docs/OAuth2Login.
            var user = controller.Session["user"];
            if (user == null)
            {
                user = Guid.NewGuid();
                controller.Session["user"] = user;
            }
            return user.ToString();

        }

        public override IAuthorizationCodeFlow Flow
        {
            get { return flow; }
        }
    }
}

网络应用程序(ASP.NET MVC)窃取的代码

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43064047

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档