Search code examples
node.jsreactjsfacebook-access-tokenfacebook-authentication

Error in facebook login from mobile browser


I am trying to login by Facebook using "react-facebook-login" and "passport-facebook-token" in nodejs. I logged successfully in the web browser but i am getting an error "URL Bloocked" in mobile browser. When i am switching to desktop mode on my phone its successfully login.

const module.exports = passport => {
passport.use(
"facebookStrategy",
new FacebookStrategy(
  {
    clientID: *****,
    clientSecret: "*****",
  },
  (accessToken, refreshToken, profile, done) => {
    User.findOne({ email: profile.emails[0].value })
      .then(user => {
        if (user) {
          return done(null, user);
        } else {
          //create new profile
          const newProfile = new Profile({
            user: newUser.id,
            username: profile.displayName,
            email: profile.emails[0].value,
            profilepic: profile.photos[0].value
          });
          newProfile
            .save()
            .catch(err =>
              console.log("Error in creating new profile " + err)
            );
          return done(null, newProfile);
        }
      })
      .catch(err => console.log(err));
  }
)

); };


Solution

  • This is common issue among mobile browsers and you will find that it would also be in some android devices.

    For precaution it is under best practice to build flow of login manually. Go here https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow

    So yes, you will need to go with manual integration. But, it will be full-proof integration without doubts.