title: firebase cloud function API Error with Google Cloud Storage
body: <p>With the introduction of Firebase Cloud Functions we are looking at moving some of our current node.js server side code to cloud functions.  One issue I am having is with downloading a file from a GCS bucket to a temp file on disk, and then emailing that as an attachment (using mailgun-js). </p>
  
  <p>The piece of code causing me grief is:</p>
  
  <pre><code>return mkdirp(tempLocalDir).then(() =&gt; {
      const bucket = gcs.bucket(gcsBucket);
      const tempFilePath = tempLocalDir + gcsFile;
      return bucket.file(gcsFile).download({
          destination: tempFilePath
      }).then(() =&gt; {
          console.log('File downloaded locally to', tempFilePath);
          var messageSubject = "Test";
          var messageBody = "Test with attach";
  
          var mailgunData = {
              from: ,
              to: agentEmail,
              subject: messageSubject,
              html: messageBody,
              attachment: tempFilePath,
          };
          mailgunAgent.messages().send(mailgunData, function (error, body) {
              console.log(body);
          });
  
      });
  
  });
  </code></pre>
  
  <p>The error message I'm getting in the Functions Logs is:</p>
  
  <pre><code>ApiError: Forbidden
      at Object.parseHttpRespMessage (/user_code/node_modules/@google-cloud/storage/node_modules/@google-cloud/common/src/util.js:156:33)
      at Object.handleResp (/user_code/node_modules/@google-cloud/storage/node_modules/@google-cloud/common/src/util.js:131:18)
      at Duplexify.&lt;anonymous&gt; (/user_code/node_modules/@google-cloud/storage/src/file.js:724:21)
      at emitOne (events.js:96:13)
      at Duplexify.emit (events.js:188:7)
      at emitOne (events.js:96:13)
      at DestroyableTransform.emit (events.js:188:7)
      at emitOne (events.js:96:13)
      at Request.emit (events.js:188:7)
      at Request.&lt;anonymous&gt; (/user_code/node_modules/@google-cloud/storage/node_modules/request/request.js:1108:14)
  </code></pre>
  
  <p>I'm been able to download the file to the /tmp/ folder on disk using request, and this will be the fallback option, but I'd really like to use the GCS tools if possible.  I "think" it's an auth error with GCS, but I'm not sure how to track that down. Do I need to have different auth parameters in the cloud functions .config() for GCS than for Firebase? If so, how do I enter them? Our GCS bucket and project pre-date the introduction of Firebase Storage, but we've successfully used it with the node functions running on our server.</p>
  
  <p>Thanks in advance,
  Zach</p>