Created
June 12, 2011 11:04
-
-
Save frostbytten/1021439 to your computer and use it in GitHub Desktop.
Connect-Auth Facebook Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example taken from https://github.com/ciaranj/connect-auth/issues/45 | |
var fbId= "xxxxxxxxxxxxx"; | |
var fbSecret= "xxxxxxxxxxxxxx"; | |
var fbCallbackAddress= "http://localhost:3000/auth/facebook_callback" | |
var cookieSecret = "node"; // enter a random hash for security | |
var express= require('express'); | |
var auth = require('connect-auth') | |
var app = express.createServer(); | |
app.configure(function(){ | |
app.use(express.bodyParser()); | |
app.use(express.methodOverride()); | |
app.use(express.cookieParser()); | |
app.use(express.session({secret: cookieSecret})); | |
app.use(auth([ | |
auth.Facebook({ | |
appId : fbId, | |
appSecret: fbSecret, | |
callback: fbCallbackAddress, | |
scope: 'email', | |
failedUri: '/noauth' | |
}) | |
])); | |
app.use(app.router); | |
}); | |
app.get('/auth/facebook', function(req, res) { | |
req.authenticate("facebook", function(error, authenticated) { | |
if (authenticated) { | |
res.redirect("/great"); | |
} | |
}); | |
}); | |
app.get('/noauth', function(req, res) { | |
console.log('Authentication Failed'); | |
res.send('Authentication Failed'); | |
}); | |
app.get('/great', function( req, res) { | |
res.send('Supercoolstuff'); | |
}); | |
app.listen(3000); |
It looks as if you are using the wrong auth OR (more likely) Facebook changed their authentication methods again. I will check upstream and let you know.
CV
…On Jul 29, 2011, at 11:15 PM, guiomie wrote:
Here is the url im redirected to: https://graph.facebook.com/oauth/authorize?redirect_uri=%2Flogin&scope=email&client_id=127045304052872&type=web_server
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/1021439
Hello, may I know if there's any updates to this gist?
I am receiving errors where no data is returned.
This was a proof-of-concept for a bug fix which has now been released. Please see the example application from https://github.com/ciaranj/connect-auth. Everything should be working according to the example middleware in the app.js
The exemple kinda lacks explanation. What does req.authenticate([req.param('method')] in the line req.authenticate([req.param('method')], function(error, authenticated) does? How do you configure properly? I read the facebook doc, but I still cant figure out how to get connect-auth working, authentication failed all the time...?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is the url im redirected to: https://graph.facebook.com/oauth/authorize?redirect_uri=%2Flogin&scope=email&client_id=127045304052872&type=web_server