0
votes

I'm using RoR 3.1 and Koala to build a Facebook Iframe app. When a new user accesses my app, the Facebook Logo and a link "Go to Facebook" is displayed in the iframe. When you click on the logo, the permissions pop up is displayed. Clicking on allow works - my app functions fine after that. I saw some other posts on this topic, but none that have led me to a solution.

This appears to be the same problem documented in this question, but the answers didn't work for me: Facebook OAuth login for iframe canvas apps displays a logo image and a Go to Facebook.com caption instead of logging in

I tried including top.location.href at the top of my index.html.erb file with the hard coded URL: top.location.href="https://www.facebook.com/dialog/permissions.request?appid=xxx, no luck.

I grabbed the link for the facebook logo and tried pasting that in to the top.location.href, no luck. FYI, the link looks like this: https://www.facebook.com/dialog/permissions.request?app_id=XXX&display=page&next=http%3A%2F%2Feowyn.simularity.com%3A3000%2Fgifty%2Fcallback&response_type=code&fbconnect=1&perms=user_likes%2Cuser_groups%2Cfriends_likes#

I read the bug posted on Facebook about it, and it was closed with "as designed". http://bugs.developers.facebook.net/show_bug.cgi?id=11326

It's a terrible user experience and I can't imagine this is what was intended. None of the other apps I use have this problem. You click on a link to go to the app, and the permissions dialog box comes up.

Adding my controller code in case it helps:

    SITE_URL="http://mysubdomain.example.com:3000/"

    def index
          @oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, SITE_URL + 'myapp/callback')
          session[:oauth] = @oauth
          redirect_to @oauth.url_for_oauth_code( :permissions =>   "user_likes,user_groups,friends_likes")
      end


      #method to handle the redirect from facebook back to you
      def callback
        #get the access token from facebook with your code
        session[:access_token] = session[:oauth].get_access_token(params[:code])
        redirect_to '/myapp/menu'
      end

      def menu

          @api = Koala::Facebook::API.new(session[:access_token])
          < app code here >

Thanks for any help! Liz

1
Have you tried adding target="_top" to your link? this will open the link in the top document. But again the redirect uri (next) should be your canvas url not the website: https://apps.facebook.com/appnamespaceifaour
@ifaour - which link should have target="_top", and which redirect call should go to apps.facebook.com/appnamespace? I added my code above so you can see what I'm doing. Thanks for your help!Liz Derr

1 Answers

0
votes

I think I have this resolved now. I was working on my app in Sandbox Mode. When I went to configure my app in Settings _> Advanced, and take it out of Sandbox Mode on Facebook, it started working. I also enabled "Enahnced Auth Dialog" and now the new, friendlier, Auth Dialog is displayed instead of the pesky Facebook Logo.

I hope this helps other folks who might be having this problem. FWIW, I didn't need to do any thing with top.location.href or javascript to get this to work.