title: Google cloud functions - cannot read property 'getApplicationDefault'
body: <p>I have deployed a cloud function to invoke a dataflow pipeline template and trying to trigger the function by placing the file in cloud storage bucket.</p>
  
  <p>As node.js prerequisite I have done,</p>
  
  <pre><code>npm init
  npm install --save googleapis
  </code></pre>
  
  <p>Index.js</p>
  
  <pre><code>const google = require('googleapis');
  
  exports.goWithTheDataFlow = function(event, callback) {
   const file = event.data;
  
  
  
     google.auth.getApplicationDefault(function (err, authClient, projectId) {
       if (err) {
         throw err;
       }
  
   console.log(projectId);
       if (authClient.createScopedRequired &amp;&amp; authClient.createScopedRequired()) {
         authClient = authClient.createScoped([
           'https://www.googleapis.com/auth/cloud-platform',
           'https://www.googleapis.com/auth/userinfo.email'
         ]);
       }
  
       const dataflow = google.dataflow({ version: 'v1b3', auth: authClient });
              console.log(`gs://${file.bucket}/${file.name}`);
       dataflow.projects.templates.create({
         projectId: projectId,
         resource: {
           parameters: {
             inputFile: `gs://${file.bucket}/${file.name}`
  
           },
           jobName: 'cloud-fn-dataflow-test',
           gcsPath: 'gs://jaison/templates/ApacheBeamTemplate'
         }
       }, function(err, response) {
         if (err) {
           console.error("problem running dataflow template, error was: ", err);
         }
         console.log("Dataflow template response: ", response);
         callback();
       });
  
     });
  
   callback();
  };
  </code></pre>
  
  <p>Command used to deploy cloud function:</p>
  
  <pre><code>gcloud beta functions deploy goWithTheDataFlow --stage-bucket cf100stage --trigger-bucket cf100
  </code></pre>
  
  <p>Dataflow(Apache beam):
  I was able to execute the dataflow template from console and below is the path of the template,</p>
  
  <pre><code>'gs://jaison/templates/ApacheBeamTemplate'
  </code></pre>
  
  <p>Function crashes with below error:</p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'getApplicationDefault' of undefined
    at exports.goWithTheDataFlow (/user_code/index.js:11:17) at
    /var/tmp/worker/worker.js:695:16 at /var/tmp/worker/worker.js:660:9 at
    _combinedTickCallback (internal/process/next_tick.js:73:7) at process._tickDomainCallback (internal/process/next_tick.js:128:9)</p>
  </blockquote>
  
  <p>Looks like I am missing libraries. Not sure how to fix this. Please help.</p>