title: gcloud run & Firebase Admin SDK
body: <p>I have deployed a JVM application to Google cloud run that uses the Firebase Admin SDK to send notifications on Firebase Cloud Messaging.
  Everything works fine locally using GOOGLE_APPLICATION_CREDENTIALS. The deployed app, however, throws errors as follows:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Project ID is required to access messaging service. Use a service account credential or set the project ID explicitly via FirebaseOptions. Alternatively you can also set the project ID via the GOOGLE_CLOUD_PROJECT environment variable.
  </code></pre>
  
  <p>I create the FirebaseMessaging instance as:</p>
  
  <pre><code>FirebaseMessaging.getInstance(
  FirebaseApp.initializeApp(
      FirebaseOptions.Builder().setCredentials(
          GoogleCredentials.getApplicationDefault()
      ).build()
  </code></pre>
  
  <p>I have deployed the Cloud Run instance with a service account which has admin permissions for Cloud Run.</p>
  
  <p>My understanding is that an application deployed to any GCP service acquires application credentials automatically. Is there a difference for the combination of Cloud Run and Firebase Admin SDK?</p>
  
  <p>Any help would be much appreciated.</p>