简体   繁体   English

使用IIS虚拟目录时出现Facebook登录错误191

[英]Facebook Login Error 191 when use IIS Virtual Directory

I already look other reference article but still can't solve my problem 我已经看过其他参考文章,但仍然无法解决我的问题

I own a site named https://shop.yourdomain.com/ 我拥有一个名为https://shop.yourdomain.com/的网站
Because all my users use Android in App view to browse my site, I manually build a facebook login flow and It works perfectly. 因为我所有的用户都在应用程序视图中使用Android浏览我的网站,所以我手动构建了一个Facebook登录流程,它可以完美运行。
(ref: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow ) (参考: https : //developers.facebook.com/docs/facebook-login/manually-build-a-login-flow

My problem is below: 我的问题如下:
I build another website and use IIS virtual directory and use it as a application and URL is 我建立了另一个网站,并使用IIS虚拟目录并将其用作应用程序,URL为
https://shop.yourdomain.com/second-site/ https://shop.yourdomain.com/second-site/

but this time when I use facebook login it will return info below. 但是这一次当我使用Facebook登录时,它将在下面返回信息。

API Error Code: 191 API错误代码:191
API Type OAuthException: OAuthException API类型OAuthException:OAuthException
API Error Description: The specified URL is not owned by the application Error Message: redirect_uri is not owned by the application. API错误说明:指定的URL不归应用程序所有错误消息:redirect_uri不归应用程序所有。

Already Set Facebook Login APP 已设置Facebook登录APP
1.Setting -> Basic -> Domain add https://shop.yourdomain.com/ 1.设置->基本->域添加https://shop.yourdomain.com/
2.Facebook login -> Setting -> Valid OAuth Redirect URI add https://shop.yourdomain.com/ 2.Facebook登录->设置->有效的OAuth重定向URI添加https://shop.yourdomain.com/
3.Redirect Strict Mode -> off 3.重定向严格模式->关闭

Ever Tried 曾经尝试过
1.I tried adding https://shop.yourdomain.com/second-site/ to Facebook login -> Setting -> Valid OAuth Redirect URI, but it still didn't work. 1.我尝试将https://shop.yourdomain.com/second-site/添加到Facebook登录->设置->有效的OAuth重定向URI,但仍然无法正常工作。

2.When I develop this website on my own computer, I use http://localhost:port/ and add http://localhost:port on facebook application setting, and login flow is work. 2.当我在自己的计算机上开发此网站时,我使用http:// localhost:port /并在facebook应用程序设置中添加http:// localhost:port ,登录流程正常。

Has anyone ever encountered a problem of that kind? 有没有人遇到过类似的问题? Please help me. 请帮我。 Thank you so much. 非常感谢。

Logic Flow Detail is below: 逻辑流详细信息如下:

1.After user click 'login' button, then Javascript redirect to Facebook Oauth 1.用户单击“登录”按钮后,然后将Javascript重定向到Facebook Oauth
location.href = "https://www.facebook.com/v2.12/dialog/oauth ?client_id=XXX &redirect_uri=https://shop.yourdomain.com/second-site/login/facebooklogin/ &state=parameters

2.(Redirect to Facebook Domain)User Login in Facebook or User auth Facebook for my website 3.Facebook HttpGet Back To my WebSite 2.(重定向到Facebook域)用户在Facebook上登录或对我的网站进行用户身份验证3.Facebook Http返回我的网站

[HttpGet]
public ActionResult FacebookLogin(string code, string error, string state)
{
    try
    {
        HttpClient client = new HttpClient();
        string facebookUrl = "https://graph.facebook.com/";
        string facebookMethod = "v2.12/oauth/access_token?client_id=XXX
        &redirect_uri=https://shop.yourdomain.com/second-site/login/facebooklogin/
        &client_secret=OOO&code=code;

        var facebookToken = client.GetAsync(facebookUrl + facebookMethod).Result;
        string facebookTokenString = facebookToken.Content.ReadAsStringAsync().Result;
        JObject facebookTokenResult = JObject.Parse(facebookTokenString);

    }
    catch(Exception e)
    {
        //Handle Exception
    }
}

4. facebookTokenResult is below 4. facebookTokenResult在下面

{
    "error":{
       "message":"Can't Load this website : this website is not include in application domain. If you want to load this website, please add all domain and subdomain in 'application domain'(I translate it in English)",
       "type":"OAuthException",
       "code":191,
       "fbtrace_id":"XXXOOO"
    }
}

I finally find the answer and is not about the any facebook setting. 我终于找到了答案,并且与任何facebook设置无关。
The problem is the http and https and I only set facebook allow https. 问题是http和https,我只设置facebook允许https。
I make a mistake that I put only http url in c# code and that is why facebook always tell me that domain is not allowed. 我犯了一个错误,我只在C#代码中放入了http url,这就是为什么facebook总是告诉我不允许使用域。

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

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