sodalive-backend-spring-boot/src/main/kotlin/kr/co/vividnext/sodalive/configs/FirebaseConfig.kt

26 lines
715 B
Kotlin

package kr.co.vividnext.sodalive.configs
import com.google.auth.oauth2.GoogleCredentials
import com.google.firebase.FirebaseApp
import com.google.firebase.FirebaseOptions
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Configuration
import java.io.FileInputStream
import javax.annotation.PostConstruct
@Configuration
class FirebaseConfig(
@Value("\${firebase.secret-key-path}")
private val secretKeyPath: String
) {
@PostConstruct
fun initialize() {
FirebaseOptions.builder()
.setCredentials(GoogleCredentials.fromStream(FileInputStream(secretKeyPath)))
.build()
FirebaseApp.initializeApp()
}
}