jaredhanson / passport-facebook

Facebook authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-facebook/?utm_source=github&utm_medium=referral&utm_campaign=passport-facebook&utm_content=about
MIT License
1.29k stars 446 forks source link

FacebookToken Error via localhost #288

Open lcy101u opened 2 years ago

lcy101u commented 2 years ago

facebook strategy

passport.use(new FacebookStrategy({
    clientID: process.env.FACEBOOK_ID,
    clientSecret: process.env.FACEBOOK_SECRET,
    callbackURL: process.env.FACEBOOK_CALLBACK,
    profileFields: ['email', 'displayName']
  }, (accessToken, refreshToken, profile, done) => {
    console.log(profile)
    //.....
  }))

authenticate

router.get('/facebook', (req, res, next) => {
  console.log('FB authentication !!!!')
  next()
},passport.authenticate('facebook', {
  scope: ['email', 'public_profile']
}))

router.get('/facebook/callback',(req, res, next) => {
  console.log('FB callback!!!!')
  next()
},  passport.authenticate('facebook', {
  successRedirect: '/',
  failureRedirect: '/users/login',
}))

This is what I got

Listening on http://localhost:3000 mongodb connected! FB authentication !!!! FB callback!!!! FacebookTokenError: Can't Load URL: The domain of this URL isn't included in the app's domains at Strategy.parseErrorResponse (D:_Projects\todo-list\node_modules\passport-facebook\lib\strategy.js:198:12) at Strategy.OAuth2Strategy._createOAuthError (D:_Projects\todo-list\node_modules\passport-oauth2\lib\strategy.js:420:16) at D:_Projects\todo-list\node_modules\passport-oauth2\lib\strategy.js:177:45 at D:_Projects\todo-list\node_modules\oauth\lib\oauth2.js:191:18 at passBackControl (D:_Projects\todo-list\node_modules\oauth\lib\oauth2.js:132:9) at IncomingMessage. (D:_Projects\todo-list\node_modules\oauth\lib\oauth2.js:157:7) at IncomingMessage.emit (events.js:327:22) at endReadableNT (internal/streams/readable.js:1327:12) at processTicksAndRejections (internal/process/task_queues.js:80:21)

What I had tried

Stackoverflow But since I use localhsot, so I left "Valid OAuth Redirect URIs" empty

Environment

blender222 commented 2 years ago

I have same problem when running in localhost. (FacebookTokenError: Can't Load URL: The domain of this URL isn't included in the app's domains)

but it works when deploy to heroku

lcy101u commented 2 years ago

@blender222 Looks like it is a bug from Meta (Facebook), I tried again in localhost and it works fine now.