簡體   English   中英

通過共享Windows托管服務器上托管的ASP.NET Web API應用程序,Google API調用失敗

[英]Google API call fails from an ASP.NET Web API application hosted on shared Windows hosting server

我已經創建了一個ASP.net Web API應用程序。 此應用程序具有一個API,可從我的Android應用程序接收sku ID和購買令牌,驗證購買並返回適當的結果。 現在的問題是,當我在本地運行應用程序時,它運行良好。 Google會給我回覆,我可以處理。 但是,當我在共享的Windows托管服務器上托管此應用程序時,此調用失敗。 它只是失敗,沒有錯誤。

這是我的Web API。

[HttpPost]
[Route("Api/Files/GetFiles")]
public HttpResponseMessage GetFiles(FileInfo fileInfo)
{
    string skuId = fileInfo.SkuId;
    string purchaseToken = fileInfo.PurchaseToken;
    ProductPurchase productPurchase = GoogleAPIConnector.GetProductPurchaseInfo(skuId, purchaseToken);
}

這是“ GetProductPurchaseInfo”函數。

public static ProductPurchase GetProductPurchaseInfo(string productId, string purchaseToken)
        {
            string packageName = "my.package.name";

            string sFileContents = "my p12 file contents as a byte array";

            byte[] baFileContents = Convert.FromBase64String(sFileContents);

            var certificate = new X509Certificate2(baFileContents,
                            "notasecret",
                            X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet
                        );

            var credentials = new ServiceAccountCredential(
                    new ServiceAccountCredential.Initializer("my publisher account on google play service")
                    {
                        Scopes = new[] { AndroidPublisherService.Scope.Androidpublisher }
                    }.FromCertificate(certificate));

            var service = new AndroidPublisherService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credentials,
                ApplicationName = "my application name",
            });

            return service.Purchases.Products.Get(packageName, productId, purchaseToken).Execute();
        }

我盡力尋找解決方案。 可能是因為在共享托管環境中禁止API調用嗎? 我認為這可能是唯一的原因,因為在本地運行應用程序時此調用成功。 還是我在服務器上缺少某些配置?

我可以通過更改網絡托管提供商來解決此問題。 我選擇了Accuwebhosting。 我使用Postman部署了稱為API的代碼,並能夠獲得響應。

因此,這是GoDaddy的錯。 (還有一個討厭他們的理由嗎?)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM