Passport-Facebook authentication is not providing email for all Facebook accounts

前端 未结 7 961
忘了有多久
忘了有多久 2020-12-07 20:16

I am using Passport-Facebook authentication.

  passport.use(new FacebookStrategy({
            clientID: \'CLIENT_ID\',
            clientSecret: \'CLIENT_SECRET\         


        
7条回答
  •  旧时难觅i
    2020-12-07 20:39

    Make sure you're providing the scope parameter into the first .authenticate() call, not the callback.

    Like this:

    router.get("/auth/facebook", passport.authenticate("facebook", {
        scope: [ "email" ], // scope goes here, not below
    }));
    
    router.get("/auth/facebook/callback",
        passport.authenticate("facebook", {
            successRedirect: "/",
            failureRedirect: "/login",
        }),
    );
    

提交回复
热议问题