我嘗試使用運行Java Spring應用程序的Heroku實例初始化Firebase Admin SDK。 Firebase說明直接引用.json文件。使用Heroku的Firebase Admin SDK
Initialize the Firebase Admin SDK
我不想直接包括我的管理SDK JSON文件在我的git倉庫,因爲我不希望我的火力點暴露的憑據。要訪問Heroku中的.json值,我已經創建了一個環境變量,其中包含Firebase Admin SDK .json文件的內容。我在當地的發展環境做同樣的事情和應用程序的工作原理是使用這種方法訪問環境VAR:
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://forrent-youtube-live.firebaseio.com/")
.build();
FirebaseApp.initializeApp(options);
當我試圖運行在Heroku的應用程序時,火力試圖初始化它崩潰。
是否有任何解決方法或其他方法來訪問不在.git倉庫中但在Heroku服務器上可用的.json文件?