【发布时间】:2015-03-03 17:59:36
【问题描述】:
我将 PassportJS 与 Node 和 Express 一起使用。我在本机 iOS 应用程序中这样做。当我通过 Node 向 Facebook 启动基于 API 的身份验证时,我得到了一个指向 Facebook 的重定向 URL,当我尝试将其加载到 Web 视图中时,我收到一条错误消息,指出“redirect_uri URL 必须是绝对的。”
这个项目没有网站,它只是一个应用程序,所以我在回调 URL 中指定了深层链接
//setup facebook authentication
passport.use(new FacebookStrategy({
clientID: "13434543",
clientSecret: "fdaf323432fadfa134",
callbackURL: "sixdwf://deeplink?facebook=/auth/facebook/callback"
},
function(accessToken, refreshToken, profile, done) {
User.findOrCreate(accessToken, refreshToken, profile, done, function(err, user) {
if (err) { return done(err); }
done(null, user);
});
}
));
// Redirect the user to Facebook for authentication. When complete,
// Facebook will redirect the user back to the application at
// /auth/facebook/callback
app.get('/auth/facebook', passport.authenticate('facebook', { scope: ['public_profile', 'email' , 'user_friends'] }));
// Facebook will redirect the user to this URL after approval. Finish the
// authentication process by attempting to obtain an access token. If
// access was granted, the user will be logged in. Otherwise,
// authentication has failed.
app.get('/auth/facebook/callback',
passport.authenticate('facebook', { successRedirect: '/',
failureRedirect: '/login' }));
// app.post("/account/login", function(req,res)
// {
// actMgr.handleLogin(req,res);
// });
知道如何克服这个问题吗?
【问题讨论】:
标签: javascript ios node.js facebook passport.js