gpt4 book ai didi

c# - Azure 上的 Google Analytics API

转载 作者:太空狗 更新时间:2023-10-29 19:51:05 26 4
gpt4 key购买 nike

我想在我的 MVC 网站中使用 google Analytics api,我使用 api 服务帐户和 oauth2 进行身份验证,在我的本地主机上没有任何问题,但一旦部署到 Azure,我就会收到 502 错误:

"502 - Web server received an invalid response while acting as a gateway or proxy server. There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server."

这是我的代码:

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 中缺少某些东西吗?

感谢您的帮助。

最佳答案

我也遇到了同样的问题,但将 X509KeyStorageFlags.MachineKeySet 传递到构造函数中也解决了我的问题。

X509Certificate2 certificate = new X509Certificate2(file, "key", X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet);

关于c# - Azure 上的 Google Analytics API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16992031/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com