Facebook oauth 不会重定向到 Facebook iframe
在使用 iframe canvas 方法实现 Facebook 应用程序时,我遇到了一种奇怪的行为。
我一直在关注 http://developers.facebook.com/docs/guides/ 上的教程canvas/ 到目前为止效果很好。
我发送身份验证的页面是(如教程所述):
https://www.facebook.com/dialog/oauth?client_id=138548612888445&redirect_uri=http://localhost:8080/test/facebook /return.jsf
但是,当我接受该应用程序并允许它访问我的个人数据时,我将被直接重定向到返回页面作为最上面的 URL然后看起来像这样:
+--------------------------------------------------+
| My Content |
| http://localhost:8080/test/facebook/return.jsf |
| ?code=...
+--------------------------------------------------+
但是,我不希望我的 URL 显示在最上面的框架中,而是显示在默认的 facebook 框架内:
+-------------------------------------------+
| Facebook header |
+--------------------------+----------------+
| My Content | Facebook right |
| | column |
+--------------------------+----------------+
奇怪的是:这只发生在用户第一次需要授权应用程序时 - 之后,当我调用 apps.facebook.com/fooapp
时,内容在 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将您的 Facebook 应用程序 url 设置为重定向 uri。或者,在 return.jsf 中执行您需要执行的操作,然后将用户转发到您的 Facebook 应用程序 URL。
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.
如果您像我一样使用:
,您需要将
top.location.href
更改为self.location.href
。If you used:
like I did, what you need to change is the
top.location.href
toself.location.href
.