护照不发送范围

Passport does not send scopes

我确实将电子邮件作为范围传递,如下所示:

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

生成的 url 是:

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 附加到 url 时它会这样做。

像这样:

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

为什么范围没有附加到 url?

我向错误的路由添加了作用域。

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