perdian
perdian

Reputation: 2843

Facebook oauth doesn't redirect into Facebook iframe

I've encountered a strange bahaviour, when implementing a Facebook app using the iframe canvas method.

I've been following the tutorial at http://developers.facebook.com/docs/guides/canvas/ which works very fine so far.

The page to which I send the authentification is (as the tutorial says):

https://www.facebook.com/dialog/oauth?client_id=138548612888445&redirect_uri=http://localhost:8080/test/facebook/return.jsf

However, when I accept the app and allow it to access my personal data, I'm being redirected directly to the return page as topmost URL which then looks like this:

+--------------------------------------------------+
|  My Content                                      |
|  http://localhost:8080/test/facebook/return.jsf  |
|  ?code=...
+--------------------------------------------------+

However I do not wish my URL to be displayed in the topmost frame but inside the default facebook frame:

+-------------------------------------------+
| Facebook header                           |
+--------------------------+----------------+
| My Content               | Facebook right |
|                          | column         |
+--------------------------+----------------+

The strange thing is: This only happens when the user needs to authorize the app for the first time - after that, when I call apps.facebook.com/fooapp the content is being displayed correctly inside the iframe.

What am I doing wrong?

Upvotes: 4

Views: 2123

Answers (2)

Shibby
Shibby

Reputation: 21

If you used:

 <script> top.location.href='$url'</script> 

like I did, what you need to change is the top.location.href to self.location.href.

Upvotes: 1

Jeff Sherlock
Jeff Sherlock

Reputation: 3544

Set your facebook app url as the redirect uri. Alternatively, do whatever you need to do in return.jsf and then forward the user to your facebook app url.

Upvotes: 2

Related Questions