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

Passport does not send scopes #258

Closed nemanjam closed 5 years ago

nemanjam commented 5 years ago

I do pass email as scope as seen here:

router.get(keys.facebookCallbackURL, passport.authenticate('facebook', {
    scope: ['public_profile', 'email'], 
    failureRedirect: '/', 
    session: false }),
    (req, res) => {
        //...
    }
);

Generated url is:

https://www.facebook.com/v3.2/dialog/oauth?response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A5000%2Fauth%2Ffacebook%2Fcallback&client_id=123977854776367

which does not ask user to grant email, but when I append &scope=email%2Cpublic_profile to url manually it does.

Like this:

https://www.facebook.com/v3.2/dialog/oauth?response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A5000%2Fauth%2Ffacebook%2Fcallback&client_id=123977854776367&scope=email%2Cpublic_profile

Why scopes are not appended to url?

nemanjam commented 5 years ago

I was adding scopes to the wrong route.

router.get(
  "/auth/google",
  passport.authenticate("google", {
    scope: ["profile", "email"]
  })
);