title: nodejs passport always going to failure URL
body: <p>I am using passport to allow logging in through Facebook on my website. Everything seems to work just fine, but callback from Facebook's site always goes to the failureRedirect even though I get all the data back from Facebook with valid tokens. Any ideas as to why this is happening?</p>
  
  <pre><code>express = require "express"
  passport = require 'passport'
  FBStrategy = require('passport-facebook').Strategy
  Properties = require "./config.json"
  
  FB_APP_ID = REMOVED
  FB_APP_SECRET = REMOVED
  
  passport.serializeUser = (user, done) -&gt;
   done null, user
  
  passport.deserializeUser = (obj, done) -&gt;
    done null, obj
  
  fb = new FBStrategy  
    clientID: FB_APP_ID
    clientSecret: FB_APP_SECRET
    callbackURL: "http://localhost/auth/facebook/callback"
    (accessToken, refreshToken, profile, done) -&gt;
      console.log "accesToken ", accessToken
      console.log "refreshToken", refreshToken
      console.log "profile", profile
      done()
  
  passport.use fb
  
  app = module.exports = express.createServer()
  app.Properties = Properties
  
  console.log "starting server"
  app.configure -&gt;
    app.set "views", "./views"
    app.set "view engine", "jade"
    app.set "view options", layout: false
    app.use express.methodOverride()
    app.use (express.static "#{__dirname}")
    app.use express.cookieParser()
    app.use express.bodyParser()
    app.use (express.session secret: REMOVED, key: REMOVED)
    app.use passport.initialize()
    app.use passport.session()
    app.use app.router
  
  app.configure "development", -&gt;
    app.listen Properties.Port
  
  
  app.get "/", (request, response) -&gt; 
    { session: Session } = request
    response.render "index"
  
  app.get "/account", (request, response) -&gt; 
    { session: Session } = request
    response.render "account"
  
  app.get "/login", (request, response) -&gt; 
    { session: Session } = request
    response.render "login", {user:request.user}
  
  app.get "/auth/facebook", passport.authenticate 'facebook'
  
  app.get "/auth/facebook/callback", passport.authenticate ('facebook', {failureRedirect: "/login"}), (req, res) -&gt;
    res.redirect "/account"
  
  
  console.log "server is ready and listening on port #{Properties.Port}"
  </code></pre>