Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@types/passport-google-oauth20
Advanced tools
TypeScript definitions for passport-google-oauth20
@types/passport-google-oauth20 provides TypeScript type definitions for the passport-google-oauth20 package, which is a Passport strategy for authenticating with Google using the OAuth 2.0 API.
Google OAuth 2.0 Strategy
This feature allows you to set up the Google OAuth 2.0 strategy for Passport. It involves configuring the strategy with your Google client ID, client secret, and callback URL, and defining a function to handle the user profile returned by Google.
const GoogleStrategy = require('passport-google-oauth20').Strategy;
passport.use(new GoogleStrategy({
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: 'http://www.example.com/auth/google/callback'
},
function(accessToken, refreshToken, profile, done) {
User.findOrCreate({ googleId: profile.id }, function (err, user) {
return done(err, user);
});
}));
Authentication Middleware
This feature demonstrates how to set up routes for initiating Google authentication and handling the callback after authentication. The middleware uses the Google strategy to authenticate users and handle success or failure scenarios.
app.get('/auth/google',
passport.authenticate('google', { scope: ['https://www.googleapis.com/auth/plus.login'] }));
app.get('/auth/google/callback',
passport.authenticate('google', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
passport-facebook is a Passport strategy for authenticating with Facebook using the OAuth 2.0 API. It is similar to passport-google-oauth20 but is used for Facebook authentication instead of Google.
passport-twitter is a Passport strategy for authenticating with Twitter using the OAuth 1.0a API. It provides similar functionality to passport-google-oauth20 but is used for Twitter authentication.
passport-github is a Passport strategy for authenticating with GitHub using the OAuth 2.0 API. It offers similar features to passport-google-oauth20 but is used for GitHub authentication.
npm install --save @types/passport-google-oauth20
This package contains type definitions for passport-google-oauth20 (https://github.com/jaredhanson/passport-google-oauth2).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/passport-google-oauth20.
These definitions were written by Yasunori Ohoka, Eduard Zintz, Tan Nguyen, and Gleb Varenov.
FAQs
TypeScript definitions for passport-google-oauth20
We found that @types/passport-google-oauth20 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.