Easily get your Google OAuth tokens
Tool for getting Google Cloud API OAuth tokens (refresh token)
http://localhost:3000/callback
.client_id
& client_secret
for usage in next step.gtokens.json
git clone https://github.com/bradoyler/google-tokens.git
client_id
and client_secret
npm install
npm start
refresh_token
to your '.gtokens.json'const GoogleTokens = require('google-tokens')
const tokens = new GoogleTokens({ client_id, client_secret }) // OAuth credentials
const scope = [
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.readonly'
]
tokens.authPrompt({ scope }) // required to pass API scope
.then(tokens => console.log('OAuthTokens:', tokens))
.catch(console.error)
refresh_token
the first-time you authenticate, but you can force to get new tokens by using the 'prompt' option, like so:tokens.authPrompt({ scope, prompt: 'consent' })
.then(tokens => console.log('OAuthTokens:', tokens))
Or you can run:
npm run refresh
auth/drive
) in scope