Gathering detailed insights and metrics for passport-google-verify-token
Gathering detailed insights and metrics for passport-google-verify-token
Gathering detailed insights and metrics for passport-google-verify-token
Gathering detailed insights and metrics for passport-google-verify-token
passport-google-strategy
passport strategy that uses google-auth library to verify id token before logging in user
@hatxor/passport-google-verify-token
Google Token strategy for Passport, let's you validate the user token server side, usefull for mobile app Google authentication for example. The validation is done by the official Google Auth library for NodeJs.
Passport strategy for authenticating with Google access tokens using the OAuth 2.0 API.
npm install passport-google-verify-token
Typescript
Module System
Node Version
NPM Version
66.2
Supply Chain
97.7
Quality
74
Maintenance
100
Vulnerability
98.9
License
TypeScript (100%)
Total Downloads
194,455
Last Day
71
Last Week
1,300
Last Month
4,689
Last Year
47,375
5 Stars
134 Commits
9 Forks
1 Watchers
2 Branches
6 Contributors
Updated on Jun 27, 2024
Minified
Minified + Gzipped
Latest Version
3.0.5
Package Id
passport-google-verify-token@3.0.5
Unpacked Size
16.01 kB
Size
5.08 kB
File Count
6
NPM Version
10.8.1
Node Version
20.10.0
Published on
Jun 27, 2024
Cumulative downloads
Total Downloads
Passport strategy for authenticating with Google access tokens using the OAuth 2.0 API.
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-google-verify-token
The Google authentication strategy leverages the Google Auth Library for Node.js to authenticates users.
Applications must supply a verify
callback which accepts the idToken
or access_token
coming from the user to be authenticated, and then calls the done
callback
supplying a parsedToken
(with all its information in visible form) and the
googleId
.
1var GoogleTokenStrategy = require("passport-google-verify-token").Strategy;
2
3passport.use(new GoogleTokenStrategy({
4 clientID: '12345.abcdefghijkl.apps.googleusercontent.com'// Specify the CLIENT_ID of the backend
5 // If other clients (such as android / ios apps) also access the google api:
6 // audience: [CLIENT_ID_FOR_THE_BACKEND, CLIENT_ID_ANDROID, CLIENT_ID_IOS, CLIENT_ID_SPA]
7 },
8 function(parsedToken, googleId, done) {
9 User.findOrCreate(..., function (err, user) {
10 done(err, user);
11 });
12 }
13 ));
When verifying an idToken, the Google Auth library verifyIdToken()
function is called, and the authentication is finished. When an access_token
is passed, however, two steps have to be made:
getTokenInfo()
function is called. This is to verify that the token is valid and not expired./oauth2/v3/userinfo
is sent. access_token
s require this second step in order to get the same user information idToken
s return.Use passport.authenticate()
, specifying the 'google-verify-token'
strategy, to authenticate requests.
1app.post('/auth/google/token', 2 passport.authenticate('google-verify-token'), 3 function (req, res) { 4 // do something with req.user 5 res.send(req.user? 200 : 401); 6 } 7);
Or using Sails framework:
1// api/controllers/AuthController.js 2module.exports = { 3 facebook: function(req, res) { 4 passport.authenticate('google-verify-token', function(error, user, info) { 5 // do stuff with user 6 res.ok(); 7 })(req, res); 8 } 9};
Clients can send requests to routes that use google-verify-token authentication using query parms, body, or HTTP headers. Clients will need to transmit the access_token
or the id_token
that are received from Google after user logs in.
GET /auth/google/token?access_token=<TOKEN_HERE>
Clients can choose to send the access token using the Oauth2 Bearer token (RFC 6750) compliant format
GET /resource HTTP/1.1
Host: server.example.com
Authorization: Bearer base64_access_token_string
Clients can transmit the access token via the body
POST /resource HTTP/1.1
Host: server.example.com
access_token=base64_access_token_string
This project is inspired by Juanma Reyes' Passport Google Id Token.
The MIT License (MIT)
Copyright (c) 2018 Abdou Bouroubi
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
4 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
Found 2/20 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreLast Day
36.5%
71
Compared to previous day
Last Week
17.2%
1,300
Compared to previous week
Last Month
32.7%
4,689
Compared to previous month
Last Year
-2.1%
47,375
Compared to previous year