Search code examples
rubyruby-on-rails-3facebook-graph-apiomniauthfb-graph

Do I need to use omniauth with fb_graph


I use omniauth to autenticate user with my rails app, I read a lot about fb_graph gem and I was wondering:

  • What does fb_graph do in plain english?
  • Can I only use omniauth if I want to grab all my user facebook friends or is omniauth only
    for authenticating users?
  • Some people use fb_graph for both authentication and grabbing user info data, which is best, to use omniauth with fb_graph or only use fb_graph?

Link to: fb_graph gem Link to: omniauth-facebook


Solution

  • fb_graph is a wrapper for the Facebook Graph API, which allows you to do a lot of things, like creating albums.

    Omniauth is like a common authentication interface between lots of service providers, like Yahoo and Facebook. You won't need to implement different authentication for different sites. This means Omniauth is centered around user authentication part of the provider APIs.

    Therefore I think it would not be possible to get provider specific information using Omniauth alone (correct me if I am wrong). Even if one can do it, it would not be clean.

    So fb_graph is a lower level API wrapper than Omniauth, therefore one can use it to authenticate + accessing other information. However if you use fb_graph to authenticate, you will have work to do to authenticate in other service providers.

    So in summary, if you want to allow uses to authenticate using different sites (like Linkedin), you want to use Omniauth. And use fb_graph to get FB specific information.

    If you only want users to login using Facebook alone, you can use fb_graph to do the authentication (you write the authentication code)