title: How to update Google Cloud Platform Legacy GAE and GCF Metadata Server endpoints
body: <p>I am using firebase cloud functions with Node to send push notifications triggered by realtime database events.</p>
  
  <p>I got this email from Google telling me to update my requests to use the v1 endpoint. The email states:</p>
  
  <p><em>Our records show that you own projects with App Engine applications or Cloud Functions that are still calling the pre-GA v0.1 and v1beta1 endpoints of the App Engine and Cloud Functions metadata server.</em></p>
  
  <p><em>Identify the projects, apps and functions which are making these requests.
  Attached to this message you will find the list of projects, applications and functions that you own that have made requests to the v0.1 and v1beta1 metadata server endpoints between Sept 26, 2019 and Nov 1, 2019.</em>
  <strong>Comment: I know what project it is.</strong></p>
  
  <p><em>Upgrade your Google client libraries to the latest versions. See supported library versions for the list of Google SDKs that require an update.</em>
  <strong>Comment: this I don't understand. Do I need to do this?</strong></p>
  
  <p><em>If you are making direct requests to the legacy Metadata Server endpoints:
  To ensure minimal interruption to your instances, please update your requests to the v1 endpoint before April 30, 2020.</em>
  <strong>Comment: I don't know if I'm making direct requests</strong></p>
  
  <p><em>How to upgrade from v1beta1 request to v1 requests:
  If you are making direct requests to the v1beta1 URI, please follow the following steps to upgrade to the v1 URI:
  Change the request URI to use v1 instead of v1beta1
  Add this header to your request: “Metadata-Flavor: Google”
  For example, if you’re currently making this request:
  curl "<a href="http://metadata.google.internal/computeMetadata/v1beta1/instance/id" rel="noreferrer">http://metadata.google.internal/computeMetadata/v1beta1/instance/id</a>"
  Upgrade to v1 as follows:
  curl "<a href="http://metadata.google.internal/computeMetadata/v1/instance/id" rel="noreferrer">http://metadata.google.internal/computeMetadata/v1/instance/id</a>” -H "Metadata-Flavor: Google"
  How to upgrade from v0.1 requests to v1 requests:
  If you are making direct requests to the v0.1 URI, please follow the following steps to upgrade to the v1 URI:
  Change the request URI to use v1 instead of v0.1
  Add this header to your request: “Metadata-Flavor: Google”
  Use these instructions to map the v0.1 properties to the v1 properties
  For example, if you’re currently making this request:
  curl "<a href="http://metadata.google.internal/0.1/meta-data/instance-id" rel="noreferrer">http://metadata.google.internal/0.1/meta-data/instance-id</a>"
  Upgrade to v1 as follows:
  curl "<a href="http://metadata.google.internal/computeMetadata/v1/instance/id" rel="noreferrer">http://metadata.google.internal/computeMetadata/v1/instance/id</a>” -H "Metadata-Flavor: Google"
  Redeploy your application
  The steps above will require another application deployment to take effect.</em></p>
  
  <p>I searched the Google Cloud support webb (as suggested in the email) and here on SO. But I don’t understand how to do this.</p>
  
  <p>Please bare in mind I’m a complete novice. Any help or advice is greatly appreciated!</p>
  
  <p><strong>UPDATE</strong>
  Apparently this function has made requests to the v0.1 and v1beta1 metadata server endpoints:</p>
  
  <pre><code>const functions = require('firebase-functions');
  const admin = require('firebase-admin');
  admin.initializeApp(functions.config().firebase);
  
  exports.sendErrorInputWasSentPush = functions.database.ref('/errorInputs/{barcode}/{date}').onWrite((change, context) =&gt; {
  
  const barcode = context.params.barcode
  const dataAfter = change.after.val()
  const input = dataAfter.input
  const pushIDs = [
      "", 
      ""]
  
  console.log(`Error input submitted.`)
  
  const payload = {
      notification: {
          title: '',
          body: '',
          sound: "default"
      }
  };
  
  const options = {
      priority: "high",
      timeToLive: 60 * 60 * 24
  };
  
  return admin.messaging().sendToDevice(pushIDs, payload, options);
  </code></pre>
  
  <p>});</p>
  
  <p>Firebase versions:</p>
  
  <pre><code>"firebase-admin": "^8.0.0",
  "firebase-functions": "^3.2.0"
  </code></pre>