node package manager

machinepack-facebook-oauth

node-machine logo machinepack-facebook-oauth

Communicate with Facebook to authenticate, get profile data, friends, likes, and more.

Installation   NPM version Build Status

$ npm install machinepack-facebook-oauth

Usage

Get the URL on facebook.com that a user should visit to allow/deny the specified Facebook Developer app (i.e. your app).

var Facebook = require('machinepack-facebook-oauth');
 
Facebook.getLoginUrl({
appId: 'YOUR_APPID',
callbackUrl: 'YOUR_CALLBACK_URI',
permissions: [ 'email', 'public_profile', 'user_friends' ],
}).exec({
// An unexpected error occurred. 
error: function (err){
 
},
// OK. 
success: function (result){
 
},
});

Generate a new access token for acting on behalf of a particular Facebook user account.

var Facebook = require('machinepack-facebook-oauth');
 
Facebook.getAccessToken({
appId: 'YOUR_APPID',
appSecret: 'YOUR_APP_SECRET',
code: 'YOUR_CODE', //code returned by the URL we get on getLoginUrl() 
callbackUrl: 'YOUR_CALLBACK_URI', //same as getLoginUrl() 
}).exec({
// An unexpected error occurred. 
error: function (err){
 
},
// OK. 
success: function (result){
 
},
});

Get information about the Facebook user with the specified access token.

var Facebook = require('machinepack-facebook-oauth');
 
Facebook.getUserByAccessToken({
access_token: 'YOUR_TOKEN',
fields: 'email, name, firts_name',
api_version: 'v2.7'
}).exec({
// An unexpected error occurred. 
error: function (err){
 
},
// OK. 
success: function (result){
 
},
});

About

This is a machinepack, an NPM module which exposes a set of related Node.js machines according to the machinepack specification. Documentation pages for the machines contained in this module (as well as all other NPM-hosted machines for Node.js) are automatically generated and kept up-to-date on the public registry. Learn more at http://node-machine.org/implementing/FAQ.

License

MIT © 2016 Mike McNeil and contributors