src/lib/Fetcher.js
/** returns a Promise that resolves if access is granted to the account, and rejects otherwise. */
returns a Promise that resolves if access is granted to the account, and rejects otherwise.
returns a Promise that resolves if access is granted to the account and rejects otherwise .
authenticate (env) {
    const googleAuth = new google.auth.JWT(env.SERVICE_ACCOUNT_EMAIL, null, env.SERVICE_ACCOUNT_PRIVATE_KEY, [
      'https://www.googleapis.com/auth/spreadsheets'
    ])
    this.auth = googleAuth
    const { sheetId } = this
    const me = this
    return new Promise((resolve, reject) => {
      googleAuth.authorize(function (err) {
        if (err) {
          reject(err)
        } else {
          console.log(`Connected to ${me.sheetName}. (${me.type} with ID ${sheetId}).`)
          console.log(`    grant access to: ${process.env.SERVICE_ACCOUNT_EMAIL}`)
          resolve(me)
        }
      })
    })
  }
authenticate ( env ) { const googleAuth = new google . auth . JWT ( env . SERVICE_ACCOUNT_EMAIL , null , env . SERVICE_ACCOUNT_PRIVATE_KEY , [ 'https://www.googleapis.com/auth/spreadsheets' ] ) this . auth = googleAuth const { sheetId } = this const me = this return new Promise ( ( resolve , reject ) => { googleAuth . authorize ( function ( err ) { if ( err ) { reject ( err ) } else { console . log ( ` ${ me . sheetName } ${ me . type } ${ sheetId } ` ) console . log ( ` ${ process . env . SERVICE_ACCOUNT_EMAIL } ` ) resolve ( me ) } } ) } ) }
returns a Promise that resolves if access is granted to the account, and rejects otherwise.
returns a Promise that resolves if access is granted to the account and rejects otherwise .