An implementation of the Facebook Login API using an Angular service.
From github
git clone [email protected]:yakovkhalinsky/ninebytes-fb-login.git ninebytes-fb-login
From bower
bower install angular-fb-login
From npm
npm install ninebytes-fb-login
- Do an
npm installto setup the example node.js app - Copy
src/fb.config.angular.js.exampletosrc/fb.config.angular.js - Edit
src/fb.config.angular.jsadding your appId inAPP_ID - Edit
app.jsadding you Facebook App Token inAPP_TOKEN - Edit
src/fb.config.angular.jsadding your app's permissions inPERMISSIONS - Edit
src/fb.config.angular.jssettingDEBUGtotruewill trigger console.log() for testing - Run
gruntin the base directory to createdistdirectory with files you can use in your project.
NOTE: Step 6 also creates a minified version of the final distribution file.
NOTE: src/fb.config.angular.js is git ignore to avoid committing credentials to the repo
The init(), login() and logout() functions of the service return a promise.
You can use this to change other function calls once these promises resolve.
For example:
fb.init(ctrlScope).then(function() {
// do something in here
});
fb.login().then(function() {
// do something in here
});
fb.logout().then(function() {
// do something in here
});
Note it is important to check the users authentication status in case either action was unsuccessful.
- Run
npm install - Run
node app.js - Visit
localhost:3000/index.htmlin your browser
There is an example route handler in app.js that you can use at localhost:3000/:authToken/:userId in your browser once the user is logged in.
Another example implementation can be found in example/fb.js.
If you used npm install ninebytes-fb-login get this module then use like so:
The example route uses the ninebytes-node-fb-login module.
See CHANGELOG.md
- Add tests