我正在将 PassportJS 与 Node 和 Express 一起使用。我正在 native iOS 应用程序中执行此操作。当我通过 Node 向 Facebook 启动基于 API 的身份验证时,我得到了一个到 Facebook 的重定向 URL,当我尝试将其加载到 Web View 中时,我收到一条错误消息,提示“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);
// });
知道如何克服这个问题吗?
最佳答案
给出绝对回调 URL,例如
www.mytestOauth.com/auth/twitter/callback
已安装
sixdwf://deeplink?facebook=/auth/facebook/callback
我也遇到了同样的问题,它有效
关于javascript - 在 native iOS 应用程序中使用 PassportJS 和 Nodejs 时出现错误 "The redirect_uri URL must be absolute",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27792386/