I have a problem with facebook auth. I am using the regular flow for oauth. It works fine for twitter and google but on some devices facebook keeps failing. Instead of being redirected to the specified redirect url, users are redirected to Facebook - log in or sign up or Facebook - log in or sign up (on mobile devices)
It works on some cases, but specifically on mobile browsers ( I am using this to authenticate users on my app) it redirects to http://m.facebook.com
Edit: for twitter and google it works. I am using the continue parameter because, even setting the Redirect Urls on the web.config, it was not working without it.
On a mobile browser on android it fails and redirects to m.facebook.com. I am able to reproduce this behavior on desktop by omitting the continue parameter and starting the flow here:
It is happening on chrome for Android. I have 2 different flows: the website and the Android/Iphone application (phonegap).
The only difference, the redirect url. For the website is an internal page, for the app is a service that returns a json.
I set the CallbackUrl on web.config for the second case, but I use the Continue parameter just to make sure.
Based on your documentation, the Continue parameter is the first one being considered to redirect:
The Continue QueryString, FormData or Request DTO variable when making the request to /auth
The Session.ReferrerUrl Url
The HTTP Referer HTTP Header
The CallbackUrl in the AuthConfig of the current AuthProvider used
SuccessRedirectUrlFilter Is a delegate as shown above, it has the last final say. It passes in the url it wants to redirect to which you can inspect and change by returning a different url to redirect to.
Yes the Location HTTP Response header is what’s tells the browser what url to redirect to, that’s not the problem that’s the symptom, it’s going to redirect to the final url in the HTTP Response Location Header. For some reason it’s getting lost on Android.
I’ve tested this in iOS and it redirects to the JSON url, so it looks like this is limited to Android, please use the SuccessRedirectUrlFilter to look at the url and force the JSON url for https://m.facebook.com/#s=1
BTW I’ve just tested your last link in and Android Emulator and I’m now seeing the JSON response as well, if you’ve changed something it appears to be working now.
I still haven’t changed it. It does not happen on every android, but on some models (people using the app report that on some motorola, sony xperia among others).
The SuccessRedirectUrlFilter sounds like the solution for this issue and I think I understand how it works, but I am not sure where do I implement it. Is there documentation for it? or Could you help me with a code snippet?
is it in the apphost?
var appSettings = new AppSettings();
Plugins.Add(new AuthFeature(
() => new CustomUserSession(),
new IAuthProvider[] {
new TwitterAuthProvider(appSettings),
new FacebookAuthProvider(appSettings),
new GoogleOAuth2Provider(appSettings)
}));
Thanks a lot, I really appreciate you taking the time to review this.
Just one more detail: I noticed that the first place where servicestack looks to redirect is not Continue, but somewhere else, I assume a cookie. Because, if I go to
Instead of taking me to twitter_page, it still takes me to facebook_page.
I mention this because, with the SuccessRedirectUrlFilter the redirection works, but the value being stored in the cookie is still m.facebook.com. So, if i log out and try to log in again with twitter, I will be redirected to m.facebook.com.