简体   繁体   English

使用Google或Facebook重定向的Owin第三方登录失败(/ Account / ExternalLoginCallback不起作用)C#MVC

[英]Owin 3rd party login with Google or Facebook redirect failed (/Account/ExternalLoginCallback not working) C# MVC

When we test our program in local server the 3rd party login works fine, but that's not the case when we publish it onto the actual server. 当我们在本地服务器上测试程序时,第三方登录可以正常工作,但是当我们将其发布到实际服务器上时并非如此。 When we use 3rd party login on actual server, it didn't work. 当我们在实际服务器上使用第三方登录时,它不起作用。

So far what we know is our server provider is using https while our IIS server setting is using http. 到目前为止,我们所知道的是我们的服务器提供程序正在使用https,而IIS服务器设置使用http。 Could this be the cause? 这可能是原因吗? If not, any idea what's the problem we are encountering? 如果没有,知道我们遇到了什么问题?

Here is the URL when we are entering account on Facebook 3rd party login page: 这是我们在Facebook第三方登录页面上输入帐户时的URL:

https://www.facebook.com/login.php?skip_api_login=1&api_key=569249369941462&signed_next=1&next=https%3A%2F%2Fwww.facebook.com%2Fv2.8%2Fdialog%2Foauth%3Fredirect_uri%3Dhttp%253A%252F%252Fwww.ipce.com.tw%252Fsignin-facebook%26state%3DwXOgKtgLeatXfqXP-Cv-Rc5EJu7AYiWQyqyN4bqtWfgZr6ncxzc9uerpXv4uSKZoSUQpWwO5AUt2YksiIP3q05GhjVUoT94kMZD5E57a2PgMaJT8oSrXh1K9lrH3g88DF0M2jtGX-DWJl-UJ66g_neu5xx1pGsIc3NBvblBjQfWM_rR6Vt8qB16GTCMqxSsQXhH4UXRDuQY5eBLSUKS7W0SRJMzDNClgMRT-VTZ7Gvv4oYTEAXnFG6qmh41o-xT5%26scope%3Demail%26response_type%3Dcode%26client_id%3D569249369941462%26ret%3Dlogin%26logger_id%3D2a07ffc7-acf8-ad97-0b9f-b45dcff38b39&cancel_url=http%3A%2F%2Fwww.ipce.com.tw%2Fsignin-facebook%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%26state%3DwXOgKtgLeatXfqXP-Cv-Rc5EJu7AYiWQyqyN4bqtWfgZr6ncxzc9uerpXv4uSKZoSUQpWwO5AUt2YksiIP3q05GhjVUoT94kMZD5E57a2PgMaJT8oSrXh1K9lrH3g88DF0M2jtGX-DWJl-UJ66g_neu5xx1pGsIc3NBvblBjQfWM_rR6Vt8qB16GTCMqxSsQXhH4UXRDuQY5eBLSUKS7W0SRJMzDNClgMRT-VTZ7Gvv4oYTEAXnFG6qmh41o-xT5%23_%3D_&display=page&locale=zh_TW&logger_id=2a07ffc7-acf8-ad97-0b9f-b45dcff38b39

and this is the URL after we login, back to our home page but /Account/ExternalLoginCallback is not called 这是我们登录后返回首页的URL,但未调用/ Account / ExternalLoginCallback

https://www.ipce.com.tw/?code=AQAUdHG-r1AxBOy1xkVm4sklkq-tBKn-9c_PAYqqpZmwiseTcKWAnTRJkoyeoZkiwReg_x7VSnMymQiWgqp0ZdnhlH1ypijH-FSyaca5BDCMJUS04x05CNVjrN5HvuRXdVJkv2OHwzqkTSWvkwC6S58nrRckIjroKjjGDqaWvldOt_0g8nFe_ZvLovj_hbdQs5SPE4M97CpPrm0ExudeEddEo1zn29RIMabS204kF445Hn73X90RTy7WpIqAINpcIIwK4XeAQMcoqoBQinaVRyjrNxjvKoAEXqBPBKKkdJn7u3bx94rFZXqHGGMJ6uth0rBSpDPJgtq0M1XMmYXfESjS&state=wXOgKtgLeatXfqXP-Cv-Rc5EJu7AYiWQyqyN4bqtWfgZr6ncxzc9uerpXv4uSKZoSUQpWwO5AUt2YksiIP3q05GhjVUoT94kMZD5E57a2PgMaJT8oSrXh1K9lrH3g88DF0M2jtGX-DWJl-UJ66g_neu5xx1pGsIc3NBvblBjQfWM_rR6Vt8qB16GTCMqxSsQXhH4UXRDuQY5eBLSUKS7W0SRJMzDNClgMRT-VTZ7Gvv4oYTEAXnFG6qmh41o-xT5#/_=_

I tried forcing http to https, but a server error 500 happened, I can't figure another way to fix the problem. 我尝试将http强制设置为https,但是发生了服务器错误500,我想不出解决此问题的另一种方法。

somebody help me please 有人请帮我

Try 1 尝试1

I set localhost server Route like this: 我将localhost服务器路由设置如下:

routes.MapRoute(
     name: "SigninFacebook",
     url: "signin-facebook",
     defaults: new { controller = "Member", action = "ExternalLoginCallback" }
);

It works! 有用! but it responded HTTP ERROR 500. 但它响应了HTTP错误500。

I tried applying the setting to actual server, well, nothing happened. 我尝试将设置应用到实际服务器,好吧,什么都没有发生。 It still redirect to our home page, and ExternalLoginCallback still not called. 它仍然重定向到我们的主页,并且仍未调用ExternalLoginCallback。 I doubt our actual server didn't get to signin-facebook Route. 我怀疑我们的实际服务器没有进入登录路线。

I suppose it happens because you provide redirect_uri=localhost. 我想这是因为您提供redirect_uri = localhost。

This parameter is used to redirect the browser page after successful 3rd party login to provide a auth code from Facebook to your server. 成功第3方登录后,此参数用于重定向浏览器页面,以从Facebook向您的服务器提供身份验证代码。

It works in your test environment because your webserver is local so browser can perform redirect to localhost. 它可以在您的测试环境中工作,因为您的Web服务器是本地服务器,因此浏览器可以执行重定向到localhost的操作。

But in production environment the real domain name should be used instead of localhost. 但是在生产环境中,应使用真实域名而不是localhost。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM