パスポートを使用して、自分の Web サイトで Facebook からログインできるようにしています。すべてが正常に機能しているように見えますが、有効なトークンを使用して Facebook からすべてのデータを取得しても、Facebook のサイトからのコールバックは常に failureRedirect に送られます。なぜこれが起こっているのかについてのアイデアはありますか?
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) ->
done null, user
passport.deserializeUser = (obj, done) ->
done null, obj
fb = new FBStrategy
clientID: FB_APP_ID
clientSecret: FB_APP_SECRET
callbackURL: "http://localhost/auth/facebook/callback"
(accessToken, refreshToken, profile, done) ->
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 ->
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", ->
app.listen Properties.Port
app.get "/", (request, response) ->
{ session: Session } = request
response.render "index"
app.get "/account", (request, response) ->
{ session: Session } = request
response.render "account"
app.get "/login", (request, response) ->
{ 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) ->
res.redirect "/account"
console.log "server is ready and listening on port #{Properties.Port}"