我确实将电子邮件作为范围传递,如下所示:
router.get(keys.facebookCallbackURL, passport.authenticate('facebook', {
scope: ['public_profile', 'email'],
failureRedirect: '/',
session: false }),
(req, res) => {
//...
}
);
生成的网址是:
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
为什么不将范围附加到网址?
答案 0 :(得分:0)
我将作用域添加到错误的路径。
router.get(
"/auth/google",
passport.authenticate("google", {
scope: ["profile", "email"]
})
);