0

我尝试登录到我的应用程序,该应用程序利用了 Google OAuth 流程。我过去已成功登录到此应用程序,方法是转到

localhost:5000/auth/google

当我选择我的电子邮件时,该过程只挂起大约一分钟,然后我得到:

TokenError: Code was already redeemed.

发生在localhost:5000/auth/google/callback,我认为这可能不是问题,因为它是我authRoutes.js下面文件中的一条路线:

const passport = require('passport');

module.exports = (app) => {
  app.get(
    '/auth/google',
    passport.authenticate('google', {
      scope: ['profile', 'email']
    })
  );

  app.get('/auth/google/callback', passport.authenticate('google'));

  app.get('/api/logout', (req, res) => {
    req.logout();
    // prove to whoever is
    // making request that
    // they are no longer signed in
    res.send(req.user);
  });

  app.get('/api/current_user', (req, res) => {
    res.send(req.user);
  });
};

我想我会通过转到localhost:5000/api/current_user哪个应该将用户的googleID和呈现_id为对象来检查,但是我得到一个空白屏幕,这意味着我没有成功登录。

我不确定这里发生了什么。

4

1 回答 1

0

当您尝试在本地应用程序中通过 Google OAuth 流程并且它只是挂起时,这不是问题。您的问题是您没有运行 MongoDB 数据库,因此您的应用程序很难根据数据库中存储的内容来验证这是新用户还是旧用户登录。

于 2018-06-21T21:14:54.163 回答