node-google-login

1.0.1 • Public • Published

Google Login

Author : Arju S Moon Build Status

A lightweight Google oAuth2 login modules, which can be used in your Node, Express.js Applications

  • Get Auth URL
  • Get User Profile & Access Token

Installation

Requires Node.js v12+ to run.

Install the dependencies and devDependencies and start the server.

$ npm install node-google-login

Usage

const NodeGoogleLogin = require('node-google-login');

const config = {
  clientID:"CLIENT_ID",
  clientSecret: "CLIENT_SECRET",
  redirectURL: "REDIRECT_URL",
  defaultScope: [
    'https://www.googleapis.com/auth/userinfo.email',
    'https://www.googleapis.com/auth/userinfo.profile',
  ]
}

const googleLogin = new NodeGoogleLogin(config);

// Generate Auth URL
const authURL = googleLogin.generateAuthUrl()
console.log(authURL);

// Get User Profiles and Access Tokens by passing the Auth code recieved from generateAuthUrl(). 
// Access token & refresh token are passed along with the response object
googleLogin.getUserProfile("AUTH_CODE").then(userProfile => {
  console.log("userProfile", userProfile);
}).catch(error => {
  console.log(error);
})

Package Sidebar

Install

npm i node-google-login

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

3.58 kB

Total Files

3

Last publish

Collaborators

  • arjusmoon