Take the 2-minute tour ×

I am trying to use the FB.ui oauth popup on a Facebook Canvas Page. I am using the latest Javascript SDK.

On a Page Tab, it works great to just do: FB.ui({method: 'oauth'}, callback); That gives me the allow access popup and then calls my callback with the response perfectly. No redirect is necessary.

However when I try the exact same thing on a Canvas, I get a FB dialog that says "An error occurred. Please try again later". Has anyone gotten it to work, or know of any workarounds?

I did have success with the top.location.href = "http://www.facebook.com/dialog/oauth?client_id=xxx&redirect_uri=xxx approach, but I would prefer to not have to redirect if possible.

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

It turns out that FB.login(callback) works fine on a canvas page, and it avoids the redirect as well.

So the answer for me was to just change the FB.ui to instead do FB.login. The response sent to the callback is slightly different from FB.ui, but very close.

FB.login(function(response) { 
  if(response && response.session) {
    //do stuff with session
share|improve this answer
Thanks, I had the same problem (and before I used FB.ui I had my own custom popup setup, which was ugly) –  Bart van Heukelom Sep 12 '11 at 20:43
add comment

What does "it does not work" mean? The popup might be blocked if it's not called in reaction to a user event (like a a mouse click).

share|improve this answer
I updated the question to explain that better. I get a FB dialog that says "An error occurred. Please try again later." –  Melinda Weathers Jun 7 '11 at 14:16
add comment

Your Answer


