2
目前,我爲我的iOS應用程序使用帶有Express和Passport-facebook-token模塊的NodeJS。我遇到了這個問題,因爲即使我們正在通過OAuth邏輯,服務總是返回401響應。這個代碼的任何想法,爲什麼它保持返回401,即使它已成功驗證,並來到我們的handleAuthentiation
方法,但沒有達到我調用console.log("THIS IS NOT BEING CALLED")
的方法?Passport-Facebook令牌不斷返回401
var http = require("http");
var express = require("express");
var bodyParser = require('body-parser');
var database = require('./database.js');
var passport = require('passport'),
FacebookTokenStrategy = require('passport-facebook-token').Strategy;
var User = require('./User.js');
var app = express();
//setup json parsing
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
//setup facebook authentication
passport.use(new FacebookTokenStrategy({
clientID: "2454efafd33r",
clientSecret: "323245343"
},
function(accessToken, refreshToken, profile, done) {
User.handleAuthentication(accessToken, refreshToken, profile, done, function(err, user) {
console.log("handleAuthentication user is " + JSON.stringify(user));
console.log("handleAuthentication error is " + JSON.stringify(err));
done(err, user);
});
}
));
app.post('/auth/facebook/token',
passport.authenticate('facebook-token'),
function(req, res) {
console.log("THIS IS NOT BEING CALLED");
// do something with req.user
res.status(200);
res.send(user);
}
);
http.createServer(app).listen(3000);
我想跟蹤調用透徹其他圖書館,我似乎無法找到具有success
定義的任何方法。我注意到done
方法被映射到驗證,然後調用success
。
即時通訊使用sails.js框架獲得相同的問題,但是這些配置中的哪一個做了魔術? – simondelliott
@simondelliott會議和護照的人做的伎倆 –