Facebook Graph API and Firefox Contacts

04-21-2010

I just finished a first cut at integrating the new Facebook Graph API with Firefox Contacts!

The integration had these steps:

  1. I set up a Facebook Application for Firefox Contacts. This is fairly standard Facebook Platform stuff, and nothing has changed here. This gave me an Application ID and an Application Secret (about which more below).
  2. I created a Contacts Importer and Discoverer subclass for Facebook. The Importer module serves to get the user's friend list into the Firefox people list, and Discoverer subclass serves to render information about a person that can be retrieved through the Graph API.
  3. I implemented the OAuth 2.0 permission flow in Firefox. This involved a certain amount of Firefox-internals hacking, because the OAuth flow depends on "web redirects," which are requests from a web server to send the web client off to another page. I had to intercept one of these redirections inside my extension to grab an identifier from the URL, and then trigger additional network steps to complete the transaction.
    An aside: The OAuth 2.0 flow involves an "application secret", which makes sense if I'm proving that I am some web service. When I am acting as a user-agent, it doesn't make sense at all, and involves putting something called a "secret" into client-side code, which means that it's not a secret in any sense. Unifying the user's authentication context with the user-agent's authentication context (that is, letting the browser do what the user can do) would fix this.
  4. I then retrieve the user's friend list, and, when requested to do so by the People discovery system, retrieve an arbitrary user's profile data and render it!

All in all, it took about seven hours of steady hacking to get it all working. That's much faster than I've been able to do anything with the old Facebook Platform API. Congrats to Bret and the team for that!

Released yet?

I'll be releasing 0.3 tomorrow morning, with Facebook and Yahoo! support, as well as people-in-the-awesomebar and the much improved discovery experience.

Until then, sources are available at hg.mozilla.org/labs/people, as always!

blog comments powered by Disqus