2013-09-29 3 views
0

이것은 여러 번 부탁되었지만 알려진 해결 방법이없는 것처럼 보입니다. 누군가이 문제를 해결하기 위해이 문제를 게시하고 있습니다.Facebook OAuth2는 사용자 이메일을 제공하지 않습니다.

NodeJS, PassportJS-Facebook을 사용하고 있습니다.

app.get("/auth/facebook", 
      passport.authenticate("facebook", { 
       scope : [ "email" ] 
      }), 
      function (req, res) { 
      }); 

처음에는 PassportJS 문제라고 생각했지만이 옵션을 제거했습니다. 그래서 https://developers.facebook.com/bugs/298946933534016 https://developers.facebook.com/bugs/429653750464521 https://developers.facebook.com/bugs/482815835078469

을 당신은 페이스 북의 OAuth는 서비스를 사용합니까이 알려진 문제에

This app needs: 
Your basic info 
Your email address ([email protected]) 

일부 링크 (아직 미해결를!) :
나는 명확하게 사용하고 있습니다 페이스 북의 사용자 계정 상태 ? 그렇다면 사용자의 이메일을 수신합니까? 방법? "곧은"방법? 해결 방법이 있습니까?

답변

6

passportjs의 Facebook 전략에는 옵션에 profileFields 필드가 있어야합니다. 옵션에서 "이메일"을 전달하십시오.

strategyOptions.profileFields = ['emails', 'first_name', 'last_name'];

다른 방법으로는 options에서 profileUrl을 무시하고 보낼 수 있습니다

페이스 북은 당신이 (이메일)에 권한이없는 필드를 무시합니다.

이 여기에 가야한다 :

passport.use(new FacebookStrategy({ 
    clientID: FACEBOOK_APP_ID, 
    clientSecret: FACEBOOK_APP_SECRET, 
    callbackURL: "http://localhost:3000/auth/facebook/callback", 
    profileUrl: " ..... ", 
    //or 
    profileFields: [ ... ]; 
    }, 
    function(accessToken, refreshToken, profile, done) { 
    // asynchronous verification, for effect... 
    process.nextTick(function() { 

     // To keep the example simple, the user's Facebook profile is returned to 
     // represent the logged-in user. In a typical application, you would want 
     // to associate the Facebook account with a user record in your database, 
     // and return that user instead. 
     return done(null, profile); 
    }); 
    } 
)); 

```

+1

'profileFields : [ "id", "name", "last_name", "link", "username", "gender", "locale", "age_range" – Poni

+1

profileUrl을 사용하면 전자 메일이 전달됩니다. 나는 Passport-Facebook 프로젝트에서 버그를 열 것 같아요. 고맙습니다 Eugenio! – Poni

+0

후속 조치 - "이메일"이 아니라 "이메일"이어야합니다. – Poni

0

당신은 설정에서 필드 '범위'를 제공해야합니다 대상 :

new FacebookStrategy({ 
    clientID: FACEBOOK_APP_ID, 
    clientSecret: FACEBOOK_APP_SECRET, 
    callbackURL: "http://localhost:3000/auth/facebook/callback", 
    profileUrl: " ..... ", 
    scope: "email", 
    //or 
    profileFields: [ ... ]; 
    } 

시도가 소스를 볼 수 있습니다.

+0

도 도움이되지 않았다. –