lib/index.js
function _tokenFlow () {
  const defer = vow.defer()
  let prompt
  const authUrl = oauth.generateAuthUrl({
    access_type: 'offline',
    scope: ['https://www.googleapis.com/auth/drive.readonly']
  })
  console.log('authorise metalsmith-google-drive by visiting: ', authUrl)
  prompt = readline.createInterface({
    input: process.stdin,
    output: process.stdout
  })
  prompt.question(
    'Enter the code from that page here (or "ok" to skip scrape): ',
    (code) => {
      prompt.close()
      if (code === 'ok') return defer.reject('skip')
      oauth.getToken(code, (err, result) => {
        if (err) {
          dbg(err)
          defer.reject(err)
        } else {
          console.log('---------- snip ----------')
          console.log(hjson.stringify(
            { 'metalsmith-google-drive': { token: result } },
            { separator: true, spaces: 2, bracesSameLine: true, quotes: 'all' }
          ))
          console.log('---------- snip ----------')
          console.log('this token is cached automatically, but you can store')
          console.log('it in a config file like config/local.js if you want.')
          valueCache.store('token', result)
          defer.resolve(result)
        }
      })
    }
  )
  return defer.promise()
}
function _tokenFlow () {
  const defer = vow.defer()
  let prompt
  const authUrl = oauth.generateAuthUrl({
    access_type: 'offline',
    scope: ['https://www.googleapis.com/auth/drive.readonly']
  })
  console.log('authorise metalsmith-google-drive by visiting: ', authUrl)
  prompt = readline.createInterface({
    input: process.stdin,
    output: process.stdout
  })
  prompt.question(
    'Enter the code from that page here (or "ok" to skip scrape): ',
    (code) => {
      prompt.close()
      if (code === 'ok') return defer.reject('skip')
      oauth.getToken(code, (err, result) => {
        if (err) {
          dbg(err)
          defer.reject(err)
        } else {
          console.log('---------- snip ----------')
          console.log(hjson.stringify(
            { 'metalsmith-google-drive': { token: result } },
            { separator: true, spaces: 2, bracesSameLine: true, quotes: 'all' }
          ))
          console.log('---------- snip ----------')
          console.log('this token is cached automatically, but you can store')
          console.log('it in a config file like config/local.js if you want.')
          valueCache.store('token', result)
          defer.resolve(result)
        }
      })
    }
  )
  return defer.promise()
}
### _tokenFlow

usually this auth flow happens in your browser, but here we do it via CLI
this fn prints the auth url, which gives the user a code to paste back in