Peter S
Peter S

Reputation: 65

Redirect loop with Facebook C# SDK for mobile users (iOS, Android)

We released our Facebook application Am I Interesting (http://apps.facebook.com/amiinteresting) earlier this week, and have since then gotten complaints that the application cannot be accessed from mobile phones, both iPhone and Android. So I tried from my fiancé’s phone, and after realizing that I had to configure a mobile URL in the Facebook application settings, I can replicate the problem and get this error message:

The mobile version of the app "Am I Interesting" is unavailable because it is misconfigured. It appears to be caught in a redirect loop.

The Facebook application configuration setting for Mobile Web URL points to http://www.amiinteresting.net.

The first redirect to the application, which is to www.amiinteresting.net (as configured), works fine. The error occurs after choosing to login and we use the Facebook C# SDK to authenticate and redirect back to the application. That redirect goes to apps.facebook.com/amiinteresting, which is what we want the “normal” web redirect to go to, but it seems that the mobile web applications for Facebook need their own domain and shouldn’t use the apps.facebook.com/XXXX format. But that's just a hypothesis of mine.

Here’s my configuration in web.config:

<facebookSettings
  appSecret="xxxxxx"
  appId="xxxxxx"
  canvasPage="http://apps.facebook.com/amiinteresting/"
  canvasUrl="http://www.amiinteresting.net/"
  secureCanvasUrl="https://www.amiinteresting.net" />

Is anyone aware of this problem and know how to fix it? I’m using version 5.3.2.0 of the SDK.

Thank you very much in advance!

// Peter

PS. My problem seems to be the same as this question: mobile version of Facebook app going into redirect loop DS.

Upvotes: 1

Views: 1353

Answers (1)

Peter S
Peter S

Reputation: 65

I finally solved this by replacing the SDK with my own custom implementation, blogged about it here: http://theazureexperience.wordpress.com/2011/12/26/authenticating-mobile-facebook-users/

The problem with the SDK for me was that it always redirected to apps.facebook.com/xxxxx, which doesn't work for mobile users, that's when the error about redirect loop and that the app is not configured correctly is displayed. I rewrote the redirection to always go to the actual application URL, in my case www.amiinteresting.net, and then that part works fine. The follow-up problem is that Facebook will post a signed_request when the app is within an IFrame (for "regular" users) and a "code" in the querystring for mobile users users, which need to be handled differently. The developer guide for authentication describes how this should be done quite well.

I didn't want to replace the SDK, but since the contributors to that project are very busy, the problem was too urgent for me to wait for a potential fix.

Upvotes: 2

Related Questions