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

FacebookTokenError #267

Open guitar9 opened 4 years ago

guitar9 commented 4 years ago

I tried everything but I get everytime this error: (translated with google translate)

FacebookTokenError: URL cannot be loaded: The domain of this URL does not exist in the domains of the app. To be able to load this URL, add all domains and subdomains to your app in the appdomain field in your app settings.
    at Strategy.parseErrorResponse (/usr/src/app/node_modules/passport-facebook/lib/strategy.js:198:12)
    at Strategy.OAuth2Strategy._createOAuthError (/usr/src/app/node_modules/passport-oauth2/lib/strategy.js:405:16)
    at /usr/src/app/node_modules/passport-oauth2/lib/strategy.js:175:45
    at /usr/src/app/node_modules/oauth/lib/oauth2.js:191:18
    at passBackControl (/usr/src/app/node_modules/oauth/lib/oauth2.js:132:9)
    at IncomingMessage. <anonymous> (/usr/src/app/node_modules/oauth/lib/oauth2.js:157:7)
    at emitNone (events.js: 111: 20)
    at IncomingMessage.emit (events.js: 208: 7)
    at endReadableNT (_stream_readable.js: 1064: 12)
    at _combinedTickCallback (internal / process / next_tick.js: 139: 11)
    at process._tickCallback (internal / process / next_tick.js: 181: 9)

This is my code:

passport.use(new FacebookStrategy({
    clientID: "XXX",
    clientSecret: "XXX",
    callbackURL: '/return'
  },
  function(accessToken, refreshToken, profile, cb) {
    return cb(null, profile);
  }));

router.get('/login/facebook',
  passport.authenticate('facebook'));

router.get('/return', 
  passport.authenticate('facebook', { failureRedirect: '/login' }),
  function(req, res) {
    console.log("Test")
    res.redirect('/');
  });

This are my settings:

Bildschirmfoto_2019-12-30_12-32-43 Bildschirmfoto_2019-12-30_12-32-56 Bildschirmfoto_2019-12-30_12-33-13

I dont know what to do. Somebody can help me? You can test it at localmelodies.com and then click on register and type a username and a city and then there is the facebook login button.

Environment

sanglnv commented 4 years ago

I has faced this issue for days, anyone can help?

sanglnv commented 4 years ago

Hi, for FacebookStrategy, the callbackURL must conclude with the full path of your /return route for example https://www.example.com/return instead of just /return Hope this help