使用Analytics Reporting API的ASP.NET在服务器上不起作用 [英] ASP.NET using analytics Reporting API does not work on server

查看:62
本文介绍了使用Analytics Reporting API的ASP.NET在服务器上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在本地主机上运行asp.net应用程序时,一切正常,但是当我在Web服务器上发布应用程序时,出现此错误:

When I run my asp.net application on local host everything works great but when i publish my app on the web server this error shows up:

Method 'ApplyAuthenticationToRequest' in type 'Google.Apis.Authentication.OAuth2.OAuth2Authenticator`1' from assembly 'Google.Apis.Authentication.OAuth2, Version=1.4.0.28223, Culture=neutral, PublicKeyToken=null' does not have an implementation.

此处是使用解析的代码的一部分

Here is part of the code that uses analytic

.............................................

.............................................

                //This is the API url which we're storing to a string
                string scope = AnalyticsService.Scopes.AnalyticsReadonly.GetStringValue();

                //For whatever reason, this is labelled wrong. It is the email address
                //that you have added as a user to your Analytics account
                string clientId = "*********@developer.gserviceaccount.com";

                //This is the physical path to the file we downloaded earlier
                //To demonstrate this, I've kept the full path to my key file.
                //Obviously, you will need to change this to match where you've
                //stored yours.
                string keyFile = @"C:\key\*************76-privatekey.p12";

                //The password Google gives you, probably the same as the one below
                string keyPassword = "notasecret";

                //Store the authentication description
                AuthorizationServerDescription desc = GoogleAuthenticationServer.Description;

                //Create a certificate object to use when authenticating
                X509Certificate2 key = new X509Certificate2(keyFile, keyPassword, X509KeyStorageFlags.Exportable);

                //Now, we will log in and authenticate, passing in the description
                //and key from above, then setting the accountId and scope
                AssertionFlowClient client = new AssertionFlowClient(desc, key)
                {
                    ServiceAccountId = clientId,
                    Scope = scope
                };

                //Finally, complete the authentication process
                //NOTE: This is the first change from the update above
                OAuth2Authenticator<AssertionFlowClient> auth =
                    new OAuth2Authenticator<AssertionFlowClient>(client, AssertionFlowClient.GetState);

                //First, create a new service object
                //NOTE: this is the second change from the update
                //above. Thanks to James for pointing this out
                AnalyticsService gas = new AnalyticsService(new BaseClientService.Initializer() { Authenticator = auth });

                //Create our query
                //The Data.Ga.Get needs the parameters:
                //Analytics account id, starting with ga:
                //Start date in format YYYY-MM-DD
                //End date in format YYYY-MM-DD
                //A string specifying the metrics

                DataResource.GaResource.GetRequest r =
                    gas.Data.Ga.Get(googleID[0]["google_analytic_id"].ToString(), "2005-01-01", DateTime.Now.ToString("yyyy-MM-dd"), "ga:visitors");

                //Specify some addition query parameters
                //    r.Dimensions = "ga:pagePath";
                r.Sort = "-ga:visitors";
                r.MaxResults = 5;

                //Execute and fetch the results of our query
                GaData d = r.Execute();


推荐答案

我有同样的问题。尚无解决方案,但:

I have the same problem. Have no solution yet, but:

我在使用.net framework 4.0的MVC项目中测试google api,在其中添加了带有nuget的google api。该项目在用于Web的VS Express 2012中运行良好,但是当我将该项目发布到运行.NET Framework版本:4.0.30319的IIS7服务器时,出现了相同的崩溃。我已验证两台计算机使用的是相同的程序集。

I testing google apis in an MVC project using .net framework 4.0, where I have added google apis with nugets. The project works fine in VS Express 2012 for web, but I got the same crash when I publish the project to an IIS7 server running .NET Framework Version:4.0.30319. I have verified that the two machines are using the same assemblies.

有些不同,我也不知道!

Something differs and I dont know what!

这篇关于使用Analytics Reporting API的ASP.NET在服务器上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆