我正在研究Node.js应用程序 . 每当我想我理解JavaScript时,就会向我抛出一个我不理解的曲线球 . 目前,我正在尝试使用passport.js来验证用户身份 . 我有以下代码(有效):

passport.authenticate('google')(req, res, function() {
  // TODO: Handle a user not authenticating

  // This is the happy path. It will always execute. However, it should only execute if a user authenticated with google.
  logger.info('user authenticated');
  res.redirect(307, '/auth-confirm');
});

我的挑战是,我需要检测用户何时无法通过Google进行身份验证 . 如果他们成功了,我需要获得访问令牌 . 但是,我不知道如何做其中任何一个因为我不理解这个调用的语法 . 具体来说,我不明白 (req, res, function() {...}) 是什么 .

该行是否表示passport.authenticate返回一个函数 . 那么,req,res和 function() { ... } 作为参数传递给 passport.authenticate 返回的函数?如果那个's the case, I still don'知道如何获取谷歌返回的访问令牌 .