Tool for generating google OAuth tokens

Downloads in past


0.0.34 years ago4 years agoMinified + gzip package size for google-tokens in KB


Tool for getting Google Cloud API OAuth tokens (refresh token)


  • To simplify getting OAuth tokens

Getting started

  1. Sign-up for a Google Cloud API account.
  1. Create an API project with an OAuth client id and add a 'Authorized redirect URI' of http://localhost:3000/callback.
  1. Obtain your client_id & client_secret from the credentials JSON file from the console

Steps to generate .gtokens.json

  1. git clone
  1. copy .gtokens.example.json to .gtokens.json
  1. fill in client_id and client_secret
  1. install & run
``` npm install npm start ```
  1. follow prompt and copy refresh_token to your '.gtokens.json'


```javascript const GoogleTokens = require('google-tokens') const tokens = new GoogleTokens({ clientid, clientsecret }) // OAuth credentials const scope = '', '' tokens.authPrompt({ scope }) // required to pass API scope .then(tokens => console.log('OAuthTokens:', tokens)) .catch(console.error) ```
NOTE: you will only get a refresh_token the first-time you authenticate, but you can force to get new tokens by using the 'prompt' option, like so:
```javascript tokens.authPrompt({ scope, prompt: 'consent' }) .then(tokens => console.log('OAuthTokens:', tokens)) ``` ----


  • add CLI support
  • allow for using shortnames (ie. auth/drive ) in scope
  • tests for all options