title: Firebase Admin SDK with Heroku
body: <p>I am attempting to initialize the Firebase Admin SDK using a Heroku instance running a Java Spring application.  The Firebase instructions reference the .json file directly.</p>
  
  <p><a href="https://firebase.google.com/docs/admin/setup#initialize_the_sdk" rel="noreferrer">Initialize the Firebase Admin SDK</a></p>
  
  <p>I do not want to include my admin SDK json file directly in my git repo because I don't want my firebase credentials exposed.  To access the .json values in Heroku I have created an environment variable with the contents of the Firebase Admin SDK .json file inside of it.  I have done the same thing in my local development environment and the app works by accessing the environment var using this method:</p>
  
  <pre><code>String serviceAccountJson = System.getenv("SERVICE_ACCOUNT_JSON");
  InputStream serviceAccount = new ByteArrayInputStream(serviceAccountJson.getBytes(StandardCharsets.UTF_8));
  FirebaseOptions options = new FirebaseOptions.Builder()
      .setCredential(FirebaseCredentials.fromCertificate(serviceAccount))'
      .setDatabaseUrl("https://myfirebase-app.firebaseio.com/")
      .build();
  FirebaseApp.initializeApp(options);
  </code></pre>
  
  <p>When I attempt to run the app in Heroku it crashes when firebase tries to initialize.</p>
  
  <p>Are there any work arounds or other methods to access a .json file that is not in a .git repo, but available on a Heroku server?</p>