简体   繁体   中英

Getting error “The redirect_uri URL must be absolute” using PassportJS and Nodejs in native iOS application

I am using PassportJS with Node and Express. I am doing so in a native iOS application. When I launch the API based authentication through Node to Facebook, I get a redirect URL to Facebook, and when I try loading that into a web-view I get an error saying "The redirect_uri URL must be absolute."

This project does not have a website, it's only an app so I'm specifying the deep link in the call-back 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);
// });

Any idea how to get past this?

give the absolute callback URL something like

www.mytestOauth.com/auth/twitter/callback

insted of

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

i also faced the same issue , it works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM