得到错误" redirect_uri URL必须是绝对的"在本机iOS应用程序中使用PassportJS和Nodejs

时间:2015-01-06 05:03:37

标签: javascript ios node.js facebook passport.js

我正在使用带有Node和Express的PassportJS。我是在原生iOS应用程序中这样做的。当我通过Node启动基于API的身份验证到Facebook时,我获得了一个重定向到Facebook的URL,当我尝试将其加载到Web视图中时,我收到一条错误消息“redirect_uri 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);
// });

知道怎么过这个吗?

1 个答案:

答案 0 :(得分:0)

给出类似

的绝对回调网址

www.mytestOauth.com/auth/twitter/callback

insted of

sixdwf://deeplink?facebook=/auth/facebook/callback

我也面临同样的问题,它有效