function _doAuth (auth) {
  if (oauth) return vow.resolve()
  dbg('doing oAuth2')
  const googleAuth = new GoogleAuth()
  oauth = new googleAuth.OAuth2(
    auth.client_id,
    auth.client_secret,
    [
      'urn:ietf:wg:oauth:2.0:oob',
      'http://localhost'
    ]
  )
  return vow.resolve()
  .then(() => {
    // see if token has been recorded in config
    let configToken = config.get('metalsmith-google-drive').token
    // no idea why google auth needs the token to be writable, but whatever
    if (configToken) configToken = config.util.cloneDeep(configToken)
    // fall back to cache (params), then do token flow
    return configToken || valueCache.retrieve('token') || _tokenFlow()
  })
  .then((token) => {
    oauth.credentials = token
  })
  .catch((err) => {
    // if some failure occurred invalidate oauth object so we don't simply
    // try to use it next time.
    oauth = false
    return vow.reject(err)
  })
}
function _doAuth (auth) {
  if (oauth) return vow.resolve()
  dbg('doing oAuth2')
  const googleAuth = new GoogleAuth()
  oauth = new googleAuth.OAuth2(
    auth.client_id,
    auth.client_secret,
    [
      'urn:ietf:wg:oauth:2.0:oob',
      'http:
    ]
  )
  return vow.resolve()
  .then(() => {
    
    let configToken = config.get('metalsmith-google-drive').token
    
    if (configToken) configToken = config.util.cloneDeep(configToken)
    
    return configToken || valueCache.retrieve('token') || _tokenFlow()
  })
  .then((token) => {
    oauth.credentials = token
  })
  .catch((err) => {
    
    
    oauth = false
    return vow.reject(err)
  })
}
function _doAuth ( auth ) { if ( oauth ) return vow . resolve ( ) dbg ( 'doing oAuth2' ) const googleAuth = new GoogleAuth ( ) oauth = new googleAuth . OAuth2 ( auth . client_id , auth . client_secret , [ 'urn:ietf:wg:oauth:2.0:oob' , 'http://localhost' ] ) return vow . resolve ( ) . then ( ( ) => { // see if token has been recorded in config let configToken = config . get ( 'metalsmith-google-drive' ) . token // no idea why google auth needs the token to be writable, but whatever if ( configToken ) configToken = config . util . cloneDeep ( configToken ) // fall back to cache (params), then do token flow return configToken || valueCache . retrieve ( 'token' ) || _tokenFlow ( ) } ) . then ( ( token ) => { oauth . credentials = token } ) . catch ( ( err ) => { // if some failure occurred invalidate oauth object so we don't simply // try to use it next time. oauth = false return vow . reject ( err ) } ) }
### _doAuth

set up the API auth structure, retrieve cached token or request one

__ tokens __
* this token lasts until invalidated.

@param {Object} auth see properties passed to googleAuth.OAuth2
### _doAuth