Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js “我如何保持”;“veify回调”;在Google Strategy(Google Oauth2.0)中是否为空?_Node.js_Oauth 2.0_Passport.js_Passport Google Oauth2 - Fatal编程技术网

Node.js “我如何保持”;“veify回调”;在Google Strategy(Google Oauth2.0)中是否为空?

Node.js “我如何保持”;“veify回调”;在Google Strategy(Google Oauth2.0)中是否为空?,node.js,oauth-2.0,passport.js,passport-google-oauth2,Node.js,Oauth 2.0,Passport.js,Passport Google Oauth2,我正在使用passport.js google-oauth20策略进行google登录。但问题是我只想使用GoogleOAuth登录,而不想在GoogleOAuth中处理“profile scope”。我只想使用google登录屏幕,一旦用户登录,我就不希望任何google个人资料数据保存在我的数据库中。换句话说,我希望我在google策略中的verify google回调为空。下面是代码 passport.serializeUser(function (user, done) { done

我正在使用passport.js google-oauth20策略进行google登录。但问题是我只想使用GoogleOAuth登录,而不想在GoogleOAuth中处理“profile scope”。我只想使用google登录屏幕,一旦用户登录,我就不希望任何google个人资料数据保存在我的数据库中。换句话说,我希望我在google策略中的verify google回调为空。下面是代码

passport.serializeUser(function (user, done) {
  done(null, user.id);
});

passport.deserializeUser(function (id, done) {
  User.findById(id, function (err, user) {
    done(err, user);
  });
});

passport.use(
  new GoogleStrategy(
    {
      clientID: process.env.GOOGLEID,
      clientSecret: process.env.GOOGLESECRET,
      callbackURL: "http://localhost:3000/auth/google/secrets",
      userProfileURL: "https://www.googleapis.com/oauth2/v3/userinfo",
    },

//I want to implement the Google strategy without the callback function given below

    function (accessToken, refreshToken, profile, cb) {
      User.findOrCreate({ googleId: profile.id }, function (err, user) {
        return cb(err, user);
      });
    }
  )
);

您如何知道有人成功登录而不在数据库中存储任何内容?