1

我一直在尝试state使用passport.js在google oauth中使用参数,但由于某种原因,身份验证url上没有状态参数。我的代码

app.get('api/auth/google', passport.authenticate('google', {
      scope:[
        'https://www.googleapis.com/auth/userinfo.profile',
        'https://www.googleapis.com/auth/userinfo.email'
      ],
      state: base64url(JSON.stringify({'kk':'vv'})),
  }));

和passport.js代码

passport.use(new GoogleStrategy({
        clientID: 'id',
        clientSecret: 'secret',
        callbackURL: 'callback',
        passReqToCallback: true,
    },function(req,accessToken, refreshToken, profile, done){
          console.log(req.query.state);
     }

));

控制台上的输出是undefined。我读过其他帖子,说要使用 base64url 编码,但仍然如此。

4

0 回答 0