Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@passport-next/passport-google-oauth2
Advanced tools
Passport strategies for authenticating with Google using ONLY OAuth 2.0.
This module lets you authenticate using Google in your Node.js applications. By plugging into Passport, Google authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
$ npm install @passport-next/passport-google-oauth2
The Google OAuth 2.0 authentication strategy authenticates users using a Google
account and OAuth 2.0 tokens. The strategy requires a verify
callback, which
accepts these credentials and calls done
providing a user, as well as
options
specifying a client ID, client secret, and callback URL.
var GoogleStrategy = require( 'passport-google-oauth2' ).Strategy;
passport.use(new GoogleStrategy({
clientID: GOOGLE_CLIENT_ID,
clientSecret: GOOGLE_CLIENT_SECRET,
callbackURL: "http://yourdomain:3000/auth/google/callback",
passReqToCallback : true
},
function(request, accessToken, refreshToken, profile, done) {
User.findOrCreate({ googleId: profile.id }, function (err, user) {
return done(err, user);
});
}
));
Avoid usage of Private IP, otherwise you will get the device_id device_name issue for Private IP during authentication.
A workaround consist to set up thru the google cloud console a fully qualified domain name such as http://mydomain:3000/ for the callback then edit your /etc/hosts on your computer and/or vm to point on your private IP.
Also both sign-in button + callbackURL has to be share the same url, otherwise two cookies will be created and it will lead to lost your session
Use passport.authenticate()
, specifying the 'google'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
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'
}));
provider always set to `google`
id
name
displayName
birthday
relationship
isPerson
isPlusUser
placesLived
language
emails
gender
picture
coverPhoto
For a complete, working example, refer to the OAuth 2.0 example.
0.3.0 (2018-11-03)
FAQs
Google (OAuth 2.0) authentication strategy for Passport.
The npm package @passport-next/passport-google-oauth2 receives a total of 861 weekly downloads. As such, @passport-next/passport-google-oauth2 popularity was classified as not popular.
We found that @passport-next/passport-google-oauth2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.