【发布时间】:2013-06-04 05:29:26
【问题描述】:
我想在我的 MVC 网站中使用谷歌分析 api,我使用 api 服务帐户和 oauth2 进行身份验证,在我的本地主机上没有问题,但是一旦我部署到 Azure,我就会收到 502 错误:
"502 - Web 服务器在充当 网关或代理服务器。你所在的页面有问题 正在寻找,无法显示。当 Web 服务器(而 作为网关或代理)联系上游内容服务器, 它收到了来自内容服务器的无效响应。”
这是我的代码:
const string ServiceAccountUser = "xxxxxxxxxx-cpla4j8focrebami0l87mbcto09j9j6k@developer.gserviceaccount.com";
AssertionFlowClient client = new AssertionFlowClient(
GoogleAuthenticationServer.Description,
new X509Certificate2(System.Web.Hosting.HostingEnvironment.MapPath("/Areas/Admin/xxxxxxxxxxxxxxxxxx-privatekey.p12"),
"notasecret", X509KeyStorageFlags.Exportable))
{
Scope = AnalyticsService.Scopes.AnalyticsReadonly.GetStringValue(),
ServiceAccountId = ServiceAccountUser //Bug, why does ServiceAccountUser have to be assigned to ServiceAccountId
//,ServiceAccountUser = ServiceAccountUser
};
OAuth2Authenticator<AssertionFlowClient> authenticator = new OAuth2Authenticator<AssertionFlowClient>(client, AssertionFlowClient.GetState);
我不知道是什么原因造成的?我在 Azure 中遗漏了什么吗?
感谢您的帮助。
【问题讨论】:
标签: c# asp.net-mvc azure oauth-2.0 google-analytics-api