google-cli-auth

0.0.1 • Public • Published

google-cli-auth

Command line helper tool to work with Google access tokens.

What?

To use the API of Google any code will need to authenticate. This tool helps you to build a command line tool that uses the Google API.

Setup

  1. To use the module you need to install it.
$ npm i google-cli-auth --save
  1. You need get create a project in the Google Developers Console

  2. In the developers console (under APIs & auth) choose Credentials.

  3. (Under "OAuth") choose Create new client ID

  4. Choose Installed Application and Other

  5. Then you can setup your code with the CLIENT ID and CLIENT SECRET like this:

require('google-cli-auth')({
      name: 'my-app' // will be used to store the token under ~/.config/my-app/token.json
    , client_id: '...' // enter client id from the developer console
    , client_secret: '...' // enter client secret from the developer console
    , scope: [] // add scopes 
}, function (error, token) {
    token.access_token // your token 
    token.token_type // token type
    token.expires_at // timestamp when this token will be expired
    token.refresh(callback) // Refreshes the token
})

Note: There is more information about Scopes in the google developer docs.

Differentiation

There is another cli tool that does cli authentication. This tool is different in the sense that the token that you will get will be stored/retreived from the users config folder and offers methods to refresh the token.

Readme

Keywords

Package Sidebar

Install

npm i google-cli-auth

Weekly Downloads

0

Version

0.0.1

License

ISC

Last publish

Collaborators

  • leichtgewicht