簡體   English   中英

使用IIS虛擬目錄時出現Facebook登錄錯誤191

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

我已經看過其他參考文章,但仍然無法解決我的問題

我擁有一個名為https://shop.yourdomain.com/的網站
因為我所有的用戶都在應用程序視圖中使用Android瀏覽我的網站,所以我手動構建了一個Facebook登錄流程,它可以完美運行。
(參考: https : //developers.facebook.com/docs/facebook-login/manually-build-a-login-flow

我的問題如下:
我建立了另一個網站,並使用IIS虛擬目錄並將其用作應用程序,URL為
https://shop.yourdomain.com/second-site/

但是這一次當我使用Facebook登錄時,它將在下面返回信息。

API錯誤代碼:191
API類型OAuthException:OAuthException
API錯誤說明:指定的URL不歸應用程序所有錯誤消息:redirect_uri不歸應用程序所有。

已設置Facebook登錄APP
1.設置->基本->域添加https://shop.yourdomain.com/
2.Facebook登錄->設置->有效的OAuth重定向URI添加https://shop.yourdomain.com/
3.重定向嚴格模式->關閉

曾經嘗試過
1.我嘗試將https://shop.yourdomain.com/second-site/添加到Facebook登錄->設置->有效的OAuth重定向URI,但仍然無法正常工作。

2.當我在自己的計算機上開發此網站時,我使用http:// localhost:port /並在facebook應用程序設置中添加http:// localhost:port ,登錄流程正常。

有沒有人遇到過類似的問題? 請幫我。 非常感謝。

邏輯流詳細信息如下:

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.(重定向到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在下面

{
    "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"
    }
}

我終於找到了答案,並且與任何facebook設置無關。
問題是http和https,我只設置facebook允許https。
我犯了一個錯誤,我只在C#代碼中放入了http url,這就是為什么facebook總是告訴我不允許使用域。

暫無
暫無

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

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