com.dipien.firebase.admin.FirebaseAdminSdkHelper.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of firebase-admin Show documentation
Show all versions of firebase-admin Show documentation
Firebase Admin library for both Android & Java apps
The newest version!
package com.dipien.firebase.admin
import com.google.auth.oauth2.GoogleCredentials
import com.google.firebase.FirebaseApp
import com.google.firebase.FirebaseOptions
import java.io.FileInputStream
import java.io.InputStream
object FirebaseAdminSdkHelper {
fun init(serviceAccountJsonPath: String) {
init(FileInputStream(serviceAccountJsonPath))
}
fun initWithServiceAccount(serviceAccount: String) {
init(serviceAccount.byteInputStream())
}
private fun init(serviceAccountStream: InputStream) {
val builder = FirebaseOptions.builder()
builder.setCredentials(GoogleCredentials.fromStream(serviceAccountStream))
val options = builder.build()
FirebaseApp.initializeApp(options)
}
}