Empower your users to easily login via Facebook with this simple angularJS module.
Note: You can find the jQuery plugin version of fblogin here.
Logging in with Facebook usually requires the following steps: * window.fbAsyncInit * FB.init * FB.login * FB.api(/me)
With this module this can all be accomplished with a single call.
Install with Bower
Include fblogin after the angularJS library.
This demo is actually referencing the jQuery plugin version of fblogin, but has the same functionality as angular-fblogin. For that reason this working example is still useful. A jQuery Plugin For Adding Facebook Login To Your Web App
If you have used the jQuery.ajax() method before, then using fblogin should seem familiar. Simply call $fblogin(options) where options is an object with the desired settings.
Note: $fblogin will need to be called from a user generated event e.g (ng-click). This is because the FB.login() method that is called internally will not trigger from a non-user generated event.
Minimal login (no permissions):
Login requesting Facebook permissions:
Return only the requested fields:
Login using promise instead of callbacks:
$fblogin returns a Promise object which gives you access to the result of fblogin's deferred tasks when they complete.
Listen for progress callbacks:
When calling $fblogin() you will be required to pass in a valid options object. Item(s) marked with * are required.
A valid Facebook App Id that must be configured to work on the domain that you are using the plugin on.
A comma seperated list of extended Facebook permissions that you wish to request from the users. By default Facebook grants permissions to a user's public profile. If you only need access to access to the public permissions then you can omit the permissions option.
A comma seperated list of Facebook fields that will limit which data is returned upon success. Make sure you have requested the appropriate permissions to access the fields provided. e.g. If you want the birthday field make sure you have requested the user_birthday permission.
A callback funtion that will be called upon success. The function will receive a data object containing the data returned from Facebook.
A callback funtion that will be called upon error. The function will receive an error object containing info related to the error thrown.
$fblogin()returns a Promise Object which gives you access to the result of fblogin's deferred tasks when they complete.
- Facebook is fickle and tends to change their API with little notice, which could potentially break this plugin. I will try my best to keep up with any changes on the FB side, but there are only so many hours in the day.