Using nodejs passport-google-oauth2 without redirect url
I am using nodepm npm passport-google-oauth2 module
I am currently using it exactly as his example shows, with a redirect URI that google oauth will call back with after successful authentication:
Example:
Server side:
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);
});
}
));
Client side:
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'
}));
I know there is a way to use Google OAuth without a redirect; it just stays on the same page somehow (google SSO). I think you can do it with just help GoogleVerifier
, not with construction new GoogleAuthorizationCodeTokenRequest()
(Java examples), but I'm lost at this point.
Questions:
-
How to use google oauth2 without redirect URI? (I know it can be done with the GoogleVerifier object in Java).
-
Am I using the wrong google SSO module in NodeJS? Is the module above for google single sign-on using OAuth2? This is for Google OAuth2, but is this the SSO way?
Thanks in advance for your help
source to share
No one has answered this question yet
Check out similar questions: