Node.js 在不使用重定向URI的情况下使用nodejs passport-google-oauth2

Node.js 在不使用重定向URI的情况下使用nodejs passport-google-oauth2,node.js,passport.js,google-oauth,passport-google-oauth2,Node.js,Passport.js,Google Oauth,Passport Google Oauth2,我正在使用nodejsnpm模块 我目前正以其示例所示的方式使用它,带有一个重定向URI,google oauth将在成功身份验证后使用该URI进行回调: 例如: 服务器端: var GoogleStrategy = require( 'passport-google-oauth2' ).Strategy; passport.use(new GoogleStrategy({ clientID: GOOGLE_CLIENT_ID, clientSecret: GOOGLE

我正在使用nodejsnpm模块

我目前正以其示例所示的方式使用它,带有一个重定向URI,google oauth将在成功身份验证后使用该URI进行回调:

例如:

服务器端:

var GoogleStrategy = require( 'passport-google-oauth2' ).Strategy;

passport.use(new GoogleStrategy({
    clientID:     GOOGLE_CLIENT_ID,
    clientSecret: GOOGLE_CLIENT_SECRET,
    callbackURL: "http://yourdormain:3000/auth/google/callback",
    passReqToCallback   : true
  },
  function(request, accessToken, refreshToken, profile, done) {
    User.findOrCreate({ googleId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));
客户端:

app.get('/auth/google',
  passport.authenticate('google', { scope: 
    [ 'https://www.googleapis.com/auth/plus.login',
      'https://www.googleapis.com/auth/plus.profile.emails.read' ] }
));

app.get( '/auth/google/callback', 
    passport.authenticate( 'google', { 
        successRedirect: '/auth/google/success',
        failureRedirect: '/auth/google/failure'
}));
我知道有一种不用重定向就能使用GoogleOAuth的方法;它只是以某种方式停留在同一个页面上(谷歌SSO)。我认为您只需要一个
谷歌验证器
,而不是构建一个
新的GoogleAuthorizationCodeTokenRequest()

问题:

  • 如何在没有重定向URI的情况下使用google oauth2?(我知道可以使用Java中的GoogleVerifier对象来完成)

  • 我是否在NodeJS中使用了错误的Google SSO模块?上面的模块是否适合使用OAuth2的Google SSO?它是为GoogleOAuth2设计的,但它是否能够支持SSO


  • 提前感谢您的帮助

    确保您了解身份验证和授权之间的区别。还要更具体地说明“使用”的含义。