502 Invalid Response when calling Google Api from Azure Website

前端 未结 2 2074
春和景丽
春和景丽 2021-02-14 04:56

When I call Google APIs from an Azure website, I get 502 - Web server received an invalid response while acting as a gateway or proxy server. The exact code wor

2条回答
  •  一向
    一向 (楼主)
    2021-02-14 05:24

    . Hi Colin Mierowsky

    Where are you create certificate, in Application_Start, or WebApiConfig Register method ?

    where use this code ?

    makecert -r -n "CN=abdullahsargin.com, E=sargin48@gmail.com" -sky exchange -b 11/01/2015 -pe -sv myhost.pvk myhost.cer
    
    pvk2pfx -pvk myhost.pvk -spc myhost.cer -pfx myhost.pfx -po Test.123
    

    In global.asax application_start

             try
            {
                var certFile = Server.MapPath("~/App_Data/myhost.pfx");
                var cert = new X509Certificate2(certFile, "Test.123",
                    X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);
            }
            catch (Exception exc)
            {
                _tools.LogError(exc);
            }
    

    . this method running success on local but in azure get 502 on this code, i test this method row and row

      var code = await _userManager.GeneratePasswordResetTokenAsync(user.Id);
    

    complete of this method

        [HttpGet, AllowAnonymous]
        public async Task ForgotPassword([FromUri] ForgotPasswordViewModel model)
        {
            try
            {               
                var code = await _userManager.GeneratePasswordResetTokenAsync(user.Id);
    
                return Request.CreateResponse(HttpStatusCode.OK, new { model = user });
    
                var url = "http://abdullahsargin.com#/account/resetPassword/" + user.Id + "/" + code;
    
                await _userManager.SendEmailAsync(user.Id, "Reset Password",
                "Please reset your password by clicking here: link");
    
                return Request.CreateResponse(HttpStatusCode.OK);
            }
            catch (Exception exc)
            {
                MyTools.LogError(exc.GetBaseException());
                return Request.CreateResponse(HttpStatusCode.BadRequest, exc.GetBaseException());
            }
        }
    

    i find at this page my solution

    ASP.NET Identity: use GeneratePasswordResetToken on Azure website

    for my solution

    public UserManager() : base(new UserStore(new MyDbContext()))
    {
        // other setup
        this.UserTokenProvider = new TotpSecurityStampBasedTokenProvider();
    }
    

提交回复
热议问题