diff --git a/src/main/java/yerong/wedle/common/config/FMCConfig.java b/src/main/java/yerong/wedle/common/config/FMCConfig.java index 1b20fef..263ef0f 100644 --- a/src/main/java/yerong/wedle/common/config/FMCConfig.java +++ b/src/main/java/yerong/wedle/common/config/FMCConfig.java @@ -3,6 +3,8 @@ import com.google.auth.oauth2.GoogleCredentials; import com.google.firebase.FirebaseApp; import com.google.firebase.FirebaseOptions; + +import java.io.ByteArrayInputStream; import java.io.IOException; import javax.annotation.PostConstruct; import org.springframework.context.annotation.Configuration; @@ -13,11 +15,11 @@ public class FMCConfig { @PostConstruct private void init() throws IOException { - String fileResourceURL = "security/wedle-94dad-firebase-adminsdk-3qavr-19fe7c2a51.json"; - ClassPathResource resource = new ClassPathResource(fileResourceURL); + String firebaseConfig = System.getenv("FIREBASE_CONFIG"); + ByteArrayInputStream serviceAccountStream = new ByteArrayInputStream(firebaseConfig.getBytes()); FirebaseOptions options = FirebaseOptions.builder() - .setCredentials(GoogleCredentials.fromStream(resource.getInputStream())) + .setCredentials(GoogleCredentials.fromStream(serviceAccountStream)) .build(); FirebaseApp.initializeApp(options);