fauthentication

Node module to integrate your Node app with Facebook authentication

FAuthentication

Node.js module to integrate quickly your Node app with Facebook OAuth authentication

1. create your Facebook app on Facebook Developers

    npm install fauthentication
/* import fauthentication */
 
var fauthentication=require('fauthentication')
 
/* set FAuthentication's options (parameters of Facebook app and callbacks) */
 
fauthentication.settings({
    client_id: 'your-app-id',
    client_secret: 'your-app-secret',
    redirect_uri: 'http://your-site-domain:your-port/fauthentication/getAccessToken',
    app: app,
    callbackfunction(accessToken){
 
        console.log('now you have access token',accessToken);
        fauthentication.getUser(function(user){
            console.log('Facebook user data',user);
            // here you can save user, log in... 
        })
 
    }
})
 
/*  set FAuthentication's url*/
 
app.get('/fauthentication/authenticate',fauthentication.auth)
app.get('/fauthentication/getAccessToken',fauthentication.getAccessToken) /* this must be according to `redirect_uri` settings (see above) */
 
 
...
<body>
    <script type="text/javascript">
        var login=function(){
            window.open('/fauthentication/authenticate?next=/', 'Facebook Login', 'width=300px, height=300');
        }
    </script> 
    <button onclick="login()">Facebook Login</button>       
</body>
...
 
git clone git@github.com:bitliner/FAuthentication.git fauthentication
 
cd fauthentication/examples/fauthentication-with-express
 
npm install
 
node app.js
 
// now in your browser go to http://localhost:3000/