Search code examples
facebookoauthfacebook-apps

What is the value of redirect_uri after authentication in a facebook page tab?


I am trying to setup a simple facebook page tab application. I have already reached the state where I get the access_token as a response from the facebook graph and seems to be correct. My problem is that after the authentication I get redirected to my facebook page tab url but outside the facebook domain and not in the page tab that the user has selected.

My application info:



    Display Name:MyContest
    Namespace:mygoodcontest
    Contact Email:[email protected]
    App Domains: [ empty ]

    Page Tab Name: Contest!
    Page Tab URL:http://[mystaticip]:8080/facebookContest/app/index.do
    Secure Page Tab URL:https://[mystaticip]:8443/facebookContest/app/index.do
    Page Tab Edit URL:https://[mystaticip]:8443/facebookContest/app/admin/

This thread seems to be exactly related to my problem and it seems to get answered irrelevantly. Redirect to Facebook page tab after authentication

and this thread, is about the same problem that I am having, but on a canvas application. Not on a facebook page tab application Facebook canvas app "redirect_uri" breaks out of iframe after authorization & authentication

What I am after, is to redirect the authenticated user inside the facebook page tab after the successful authorization.

Thank you all for your time!


Solution

  • If anyone is in the same position as I was, here is what I managed to do with @darvex's help. The thing is that facebook needs the redirect_url param definitely. Also, the redirect_url param must be the same with the page tab url in edit page options. So what I understood is that facebook redirects all users outside facebook (in this case "outside facebook" means your server , your page) then, you have to handle this http GET and as @darvex said, to redirect the request to your facebook page tab with a javascript command.

    The magic happens when you redirect to your facebook page tab e.g. www.facebook.com/mypage/app_12345678 , the request comes to your handle because someone has requested your page tab. But, this time facebook has registered that this particular user has authenticated the app and thus, the http POST that is being processed at the time, has a signed_request param which if you break/decode(base64), you will find inside the access token that you need. At that point, you have a logged in user looking at your page tab - inside facebook- and an access token to do your tricks.

    I don't know if this is the best practice, but seems to work. Please if anyone has a better approach feel free to post it.

    thank you all