我在windows azure上托管了asp.net mvc项目,我正在使用谷歌分析服务及其在我的localhost上正确认证,但在托管服务器上它不起作用。它给了我这个错误"请求中的重定向URI,回调,与OAuth客户端的授权不匹配"
我的托管网址是" http://mysite.azurewebsites.net/"我在谷歌控制台提供的回调网址是" http://ispycms.azurewebsites.net/Dashboard/Index"
下面是用于对google analytic进行身份验证的C#代码,请注意我正在使用服务实例发出请求,我已将此代码放在Controller Dashboard的Index方法中。
[SessionExpireFilter]
public ActionResult Index()
{
var result = new AuthorizationCodeMvcApp(this, new AppAuthFlowMetadata()).
AuthorizeAsync(CancellationToken.None);
if (result.Result.Credential != null)
{
service = new AnalyticsService(new BaseClientService.Initializer
{
HttpClientInitializer = result.Result.Credential,
ApplicationName = "iSPY Stats"
});
}
//Request data
// make a request
var request = service.Data.Ga.Get(
"ga:" + profileId,
"2016-01-01",
"2016-05-05",
"ga:totalEvents");
request.Dimensions = "ga:eventCategory,ga:eventAction,ga:eventLabel,ga:date,ga:hour,ga:minute";
request.Filters = "ga:eventCategory==Pack;ga:eventAction==Open";
// run the request and get the data
return request.Execute();