1

我正在尝试通过passport-github获取 github 用户的私人电子邮件。
所以这是我的代码scope: "user:email"

   import passport from "passport";    
    import GithubStrategy from "passport-github";
    
    passport.use(
      new GithubStrategy(
        {
          clientID: process.env.GH_CLIENT_ID,
          clientSecret: process.env.GH_CLIENT_SECRET,
          callbackURL: `http://localhost:4000${routes.ghLoginCallback}`,
          scope: "user:email",
        },
        async (accessToken, refreshToken, profile, cb) => {
          console.log(profile.emails);
        }
      )
    );

现在我undefinedprofile.emails.
我确实得到了我的profile正确,但email:null也有。
是否有我遗漏的任何可能的问题?

4

1 回答 1

0

是的,正如@jasonandmonte 提到的,passport-github2为我工作!非常感谢。
但是,有些人说这只passport-github适用于他们(查看@jasonandmonte 提到的线程),因此将来遇到相同问题的任何人都可以尝试两者。(结构几乎相同。)

于 2020-10-15T04:44:11.410 回答