Initialize Auth
The following methods provide various ways to initialize a FirebaseApp instance, offering more specific control over initialization parameters.
Method 1: Initialize with Environment Variables
Use the initializeAppWithEnvironmentVariables method to initialize a FirebaseApp using API key, project ID, and bucket name.
FirebaseApp firebaseApp = FirebaseApp.initializeAppWithEnvironmentVariables(
apiKey,
projectId,
bucketName,
);Parameters
apiKey (
String): Your Firebase API key.projectId (
String): Your Firebase project ID.bucketName (
String): The Cloud Storage bucket associated with the Firebase project.
Return
FirebaseApp: Returns an initialized
FirebaseAppinstance.
Method 2: Initialize with Service Account
Use the initializeAppWithServiceAccount method to initialize a FirebaseApp using a service account for server-side Firebase operations.
FirebaseApp firebaseApp = FirebaseApp.initializeAppWithServiceAccount(
serviceAccountContent,
serviceAccountKeyFilePath,
);Parameters
serviceAccountContent (
ServiceAccountContent): The content of the service account key.serviceAccountKeyFilePath (
String): The file path to the service account key.
Return
FirebaseApp: Returns an initialized
FirebaseAppinstance.
Method 3: Initialize with Service Account Impersonation
Use the initializeAppWithServiceAccountImpersonation method to initialize a FirebaseApp by impersonating a service account on behalf of a user.
Return
FirebaseApp: Returns an initialized
FirebaseAppinstance.
These methods provide flexible ways to initialize Firebase in your application, depending on your environment and authentication needs.
Last updated