I am following the example at facebook Connect-auth exemple. I don’t understand how to get this example working.
In this snippet of code taken from the previous link:
// Method to handle a sign-in with a specified method type, and a url to go back to ...
app.get('/signin', function(req,res) {
req.authenticate([req.param('method')], function(error, authenticated) {
if(authenticated ) {
res.end("<html><h1>Hello Facebook user:" + JSON.stringify( req.getAuthDetails() ) + ".</h1></html>");
}
else {
res.end("<html><h1>Facebook authentication failed: " + error + " </h1></html>");
}
});
});
I do not understand what this does [req.param('method')] mean? It it hard to understand how connect-auth and facebook work together. I keep getting authentication failed.
The first argument to
authenticateis an array of authentication strategies to try, in this example thereq.param['method']is set in the URL (var sign_in_linkfurther down in the code) to “facebook” which matches the one and only authentication strategy initialized in theuse.