I already look other reference article but still can't solve my problem
I own a site named 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.
(ref: 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
https://shop.yourdomain.com/second-site/
but this time when I use facebook login it will return info below.
API Error Code: 191
API Type OAuthException: OAuthException
API Error Description: The specified URL is not owned by the application Error Message: redirect_uri is not owned by the application.
Already Set Facebook Login APP
1.Setting -> Basic -> Domain add https://shop.yourdomain.com/
2.Facebook login -> Setting -> Valid OAuth Redirect URI add https://shop.yourdomain.com/
3.Redirect Strict Mode -> off
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.
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.
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
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
[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
{
"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.
The problem is the http and https and I only set facebook allow 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.