在 Firefox 插件中验证 facebook 用户
我正在尝试编写一个 Firefox 插件来访问 facebook 的数据。 现在我不确定如何获取访问令牌。 我尝试为桌面应用程序实现客户端流程(使用固定的重定向 uri),但我遇到的大问题是 JavaScript 不允许我等待重定向发生。 知道如何做到这一点吗?
据我了解,因为我没有网页,所以 JavaScript API 没有多大帮助,对吗?
I'm trying to write a Firefox plug-in that accesses data from facebook.
Now I'm not sure how to get an access token.
I tried to implement the client side flow for desktop apps (with the fixed redirect uri), but the big problem I encounter there, is that JavaScript doesn't allow me to wait for the redirect to happen.
Any idea how this could be done?
As far as I understood it, because I don't have a webpage, the JavaScript API doesn't help much, right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜您正在浏览器选项卡中打开
https://www.facebook.com/dialog/oauth
让用户登录并授予您访问权限。您不需要在此处传递有效的重定向 URL,您可以使用肯定不起作用的内容,例如http://my.extension.local/
。然后您只需要检测选项卡何时重定向到该 URL。如果您有经典扩展,则可以在< 上注册一个 进度监听器。该选项卡的 browser>
元素并查看onLocationChange()
调用 - 一旦您看到以http://my.extension.local/
开头的位置,您就可以能取消请求并关闭选项卡,必要的数据位于 URL 中。如果您使用附加 SDK,您可以附加选项卡的ready
事件侦听器,大致如下:I guess that you are opening
https://www.facebook.com/dialog/oauth
in a browser tab to let the user log in and give you access. You don't need to pass a working redirect URL here, you can rather use something that will definitely not work, likehttp://my.extension.local/
. Then you only need to detect when the tab gets redirected to that URL. If you have a classic extension, you register a progress listener on the<browser>
element of that tab and look atonLocationChange()
calls - once you see a location starting withhttp://my.extension.local/
you can cancel the request and close the tab, the necessary data is in the URL. If you use the Add-on SDK you can attach aready
event listener to the tab, something along these lines: