Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

passport-token-google

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-token-google

Google token authentication strategy for Passport.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
190
decreased by-7.32%
Maintainers
1
Weekly downloads
 
Created
Source

Passport-Token-Google

This is an updated version of Passport-Google-Token

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 and Koa.

Installation

$ npm install passport-token-google

Usage

Configure Strategy

The Google 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 app ID and app secret.

const GoogleStrategy = require('passport-token-google').Strategy

passport.use(new GoogleStrategy({
    clientID: GOOGLE_CLIENT_ID,
    clientSecret: GOOGLE_CLIENT_SECRET
  },
  function(accessToken, refreshToken, profile, done) {
    fetchGoogleUser(profile, accessToken)
      .then((user) => done(null, user))
      .catch((err) => {
        // Handle the error
        done(null, {})
      });
  }
));
Authenticate Requests

Use passport.authenticate('google-token') to authenticate requests.

router.get('/auth/google/token', passport.authenticate('google-token'), someFunction);

GET request need to have access_token and optionally the refresh_token in either the query string or set as a header. If a POST is being preformed they can also be included in the body of the request.

Keywords

FAQs

Package last updated on 06 Aug 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc