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

google-oauth-utility

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-oauth-utility

google-oauth-utility ====

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

google-oauth-utility

Why this module

This is a module simplify the Google Oauth2 3 way handshack flow. Google's Oauth2 3 way handshack should participate with human, and we can use refresh token for extend the token's life. The module is use for transparent the refresh token exchange another token process. And user just need to do the first time to generate token file.

Generate token file

Using os path web application account.

gnutil -d [path-to-tmp-file]

The os path config file:

{
  "CLIENT_ID":"429************kunu.apps.googleusercontent.com",
  "CLIENT_SECRET":"yq***********0A",
  "REDIRECT_URL":"http://localhost:8888/oauth2callback",
  "DEFAULT_SCOPES": [
    "https://www.googleapis.com/auth/userinfo.profile",
    "https://www.googleapis.com/auth/userinfo.email",
    "https://www.googleapis.com/auth/plus.me"
  ]
}

In Mac or linux, you can put the config file under $HOME. In windows, please set the %HOME% for your system to let the module can find a path to store the file.

Using your own credential in command line:

gnutil -d [path-to-tmp-file] \
	-c [your-client-id] \
  -k [your-secret-key] \
  -u [your-redirect-url] \
  -s [your-scopes]

Usage

var oauth = require('google-oauth-utility');
var scopes = [ 'https://www.googleapis.com/auth/calendar',
  'https://www.googleapis.com/auth/userinfo.profile',
  'https://www.googleapis.com/auth/userinfo.email'
  ];

var opts = {
  clientId:'your-client-id',
  clientSecret:'your-client-secret',
  redirectUrl: 'your-redirect-url',
  tmpPath:'/tmp/.gauth'
};

oauth.authflow(scopes, opts, function(err, tokens){
  if(err) log.error(err);
  console.log('process end..........');
  console.log(tokens);
});

The function authflow will auto save the token to the tmpPath path. And if the path file exist, system will use the token file's refresh token to exchange token. The user side will no-need to join the token retrieve flow. If the tmpPath file not exist, user need join to do the Oauth2 auth flow.

FAQs

Package last updated on 02 Nov 2014

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