在一个Firefox验证Facebook的用户插件 [英] Authenticate a facebook user in a Firefox plug-in

查看:184
本文介绍了在一个Firefox验证Facebook的用户插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写一个Firefox插件,它从Facebook访问数据。
现在,我不知道如何获得访问令牌。
我试图实现对桌面应用程序的客户端流量(与固定的重定向URI),但是大问题,我碰到有,就是JavaScript并没有让我等待重定向发生。
任何想法如何可以这样做?

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?

据我的理解,因为我没有一个网页时,JavaScript API并没有多大帮助,对吧?

As far as I understood it, because I don't have a webpage, the JavaScript API doesn't help much, right?

推荐答案

我猜你正在打开 https://www.facebook.com/dia​​log/oauth 中浏览器选项卡,让用户登录并授予权限。你并不需要在这里传递一个工作重定向URL,你可以使用相当的东西,肯定是不行的,像 HTTP://my.extension.local/ 。然后,你只需要在标签被重定向到URL检测。如果你有一个经典的扩展​​,您注册的一个进步监听 <浏览器>的标签元素,并在 onLocationChange看()呼叫 - 一旦你看到某个位置开始 HTTP://my.extension.local/ 您可以取消该请求,并关闭该标签,必要的数据是在URL中。如果您使用附加SDK 可以附加就绪事件监听器到标签,沿着这些路线的内容:

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, like http://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 at onLocationChange() calls - once you see a location starting with http://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 a ready event listener to the tab, something along these lines:

var tabs = require("tabs");
tabs.open({
  url: "https://www.facebook.com/dialog/oauth?...",
  inBackground: false,
  onReady: function(tab)
  {
    if (tab.url.indexOf("http://my.extension.local/") == 0)
    {
      ...
    }
  }
});

这篇关于在一个Firefox验证Facebook的用户插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆