javascript - 在 native iOS 应用程序中使用 PassportJS 和 Nodejs 时出现错误 "The redirect_uri URL must be absolute"

标签 javascript ios node.js facebook passport.js

我正在将 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/

相关文章:

javascript - Div 元素未引导点击以启用拖动功能

iphone - Apple 推送通知不适用于分发,但适用于开发

ios - 通过 AlamofireImage 下载 UIImage?

angularjs - 使用 Node.js 和 Angular.js 列出简单的目录,注意新文件

node.js - 在 MongoDB 中删除时自动删除引用对象

javascript - 如何使用 HTML5 canvas 绘制 donut

Javascript/jQuery,动画结束后显示div

javascript - 更好的策略 : Use JS SetTimeout to check session on interval, 或检查 ajax 请求的 session

当 native 闹钟响起时发送推送通知的 iOS 应用程序

javascript - DerbyJS 从集合中查找记录