Facebook example not working in Connect-auth/Express
I am following the example at facebook C开发者_高级运维onnect-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 authenticate
is an array of authentication strategies to try, in this example the req.param['method']
is set in the URL (var sign_in_link
further down in the code) to "facebook" which matches the one and only authentication strategy initialized in the use
.
精彩评论