title: firebase functions - `firebase deploy` - The service is currently unavailable
body: <p>I am trying to run <code>firebase deploy</code> but I get:</p>
  <pre><code>=== Deploying to ...
  
  i  deploying functions
  i  functions: ensuring necessary APIs are enabled...
  ✔  functions: all necessary APIs are enabled
  i  functions: preparing functions directory for uploading...
  i  functions: packaged functions (49.59 KB) for uploading
  ✔  functions: functions folder uploaded successfully
  i  functions: updating Node.js 6 function sendMessageNotification(us-central1)...
  ⚠  functions: failed to update function sendMessageNotification
  HTTP Error: 503, The service is currently unavailable.
  
  
  Functions deploy had errors. To continue deploying other features (such as database), run:
      firebase deploy --except functions
  
  Error: Functions did not deploy properly.
  
  Having trouble? Try firebase deploy --help
  </code></pre>
  <p>FYI, this is happening after one of my service accounts was compromised because I accidentally uploaded a service account <code>json</code> file, with my credentials in it, to github. I went through the procedures described <a href="https://cloud.google.com/security/compromised-credentials" rel="nofollow noreferrer">here</a> after my account got suspended, and I successfully got it reinstated. This problem has only started happening after I removed and created all the necessary credentials (API key/service account/ouath client id).</p>
  <p>I have tried <code>firebase logout</code> then <code>firebase login</code> and was unsuccessful deploying. I also have tried <code>npm install -g firebase-tools@latest</code> and <code>firebase use --add &lt;myproject&gt;</code> (I'm not sure what that was supposed to do). I even reran the <code>firebase-tools</code> install but that still didn't help.</p>
  <p>I have also tried editing the <code>firebase</code> function from the <code>google cloud console</code> but it doesn't let me save, it gives me an <code>undefined</code> error, and a tracking number for the issue, I provided feedback but haven't heard anything.</p>
  <p>Any ideas would be greatly appreciated.</p>
  <p><strong>UPDATE</strong></p>
  <p>Here is my credentials page, I'm not exactly sure if everything is configured correctly, hopefully some info can be gained from this as I think maybe the project being compromised and having to renew the keys has something to do with the <code>firebase deploy</code> problem:</p>
  <p><strong>UPDATE</strong></p>
  <p>I have also tried resetting <code>gcloud</code> credentials with no luck:</p>
  <p><code>./gcloud auth application-default login</code></p>
  <p><strong>UPDATE</strong></p>
  <p>I ran <code>firebase deploy --only functions --debug</code>, here is more output:</p>
  <blockquote>
  <p>i  functions: updating Node.js 6 function
  sendMessageNotification(us-central1)... [2018-09-20T22:28:14.587Z]
  Trigger is:
  {&quot;eventTrigger&quot;:{&quot;resource&quot;:&quot;projects/PROJECT_ID/databases/(default)/documents/messages/{messageId}&quot;,&quot;eventType&quot;:&quot;providers/cloud.firestore/eventTypes/document.write&quot;,&quot;service&quot;:&quot;firestore.googleapis.com&quot;}}
  [2018-09-20T22:28:14.588Z] &gt;&gt;&gt; HTTP REQUEST PATCH
  <a href="https://cloudfunctions.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/functions/sendMessageNotification" rel="nofollow noreferrer">https://cloudfunctions.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/functions/sendMessageNotification</a>
  query params:
  {&quot;updateMask&quot;:&quot;sourceUploadUrl,name,labels,eventTrigger.resource,eventTrigger.eventType,eventTrigger.service&quot;}
  sourceUploadUrl=https://storage.googleapis.com/
  name=projects/PROJECT_ID/locations/us-central1/functions/Function,
  deployment-tool=cli-firebase,
  resource=projects/PROJECT_ID/databases/(default)/documents/messages/{messageId},
  eventType=providers/cloud.firestore/eventTypes/document.write,
  service=firestore.googleapis.com [2018-09-20T22:28:15.055Z] &lt;&lt;&lt; HTTP
  RESPONSE 503 vary=X-Origin, Referer, Origin,Accept-Encoding,
  content-type=application/json; charset=UTF-8, date=Thu, 20 Sep 2018
  22:28:15 GMT, server=ESF, cache-control=private, x-xss-protection=1;
  mode=block, x-frame-options=SAMEORIGIN,
  x-content-type-options=nosniff, alt-svc=quic=&quot;:443&quot;; ma=2592000;
  v=&quot;44,43,39,35&quot;, accept-ranges=none, connection=close
  [2018-09-20T22:28:15.056Z] &lt;&lt;&lt; HTTP RESPONSE BODY code=503,
  message=The service is currently unavailable., status=UNAVAILABLE ⚠
  functions: failed to update function sendMessageNotification HTTP
  Error: 503, The service is currently unavailable</p>
  </blockquote>
  <p>Interesting, if you click <a href="https://cloudfunctions.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/functions/FUNCTION" rel="nofollow noreferrer">https://cloudfunctions.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/functions/FUNCTION</a> (from the output), it brings you to this:</p>
  <pre><code>{
    &quot;error&quot;: {
      &quot;code&quot;: 401,
      &quot;message&quot;: &quot;Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.&quot;,
      &quot;status&quot;: &quot;UNAUTHENTICATED&quot;
    }
  }
  </code></pre>
  <p>It says I am missing an authentication credential...</p>
  <p><strong>UPDATE</strong></p>
  <p>When I click the <code>url</code> in the above output, it says:</p>
  <pre><code>&lt;Error&gt;
  &lt;Code&gt;SignatureDoesNotMatch&lt;/Code&gt;
  &lt;Message&gt;
  The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.
  &lt;/Message&gt;
  &lt;StringToSign&gt;
  GET 1537484293 /Function-upload-us-central1/FILE.zip
  &lt;/StringToSign&gt;
  &lt;/Error&gt;
  </code></pre>
  <p><strong>UPDATE</strong></p>
  <p>From google's <code>OAuth 2.0 Playground</code>:</p>
  <pre><code>GET /FUNCTION-central1-FILE.zip?GoogleAccessId=Service_Account@gcf-admin-robot.iam.gserviceaccount.com&amp;Expires= HTTP/1.1
  Host: storage.googleapis.com
  Content-length: 0
  Authorization: Bearer 
  HTTP/1.1 403 Forbidden
  Content-length: 298
  Expires: Thu, 20 Sep 2018 23:01:16 GMT
  X-guploader-uploadid: 
  Cache-control: private, max-age=0
  Date: Thu, 20 Sep 2018 23:01:16 GMT
  Content-type: application/xml; charset=UTF-8
  &lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;Error&gt;&lt;Code&gt;AccessDenied&lt;/Code&gt;&lt;Message&gt;Access denied.&lt;/Message&gt;&lt;Details&gt;user@gmail.com does not have storage.objects.get access to Function-us-central1-FILE.zip.&lt;/Details&gt;&lt;/Error&gt;
  </code></pre>
  <p>In short it says:</p>
  <p>user@gmail.com does not have storage.objects.get access to gFunction-us-central1-FILE.zip</p>