I'm new to Unity as well as to C# (real noob to C# and all the .NET stuff) and I want to use the Firebase Realtime Database in my Unity project. I was following the instructions on the Firebase docs to set things up, but after I created a new p12 file and added this code to my project
void Start() {
// Set these values before calling into the realtime database.
FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://YOUR-FIREBASE-APP.firebaseio.com/");
FirebaseApp.DefaultInstance.SetEditorP12FileName("YOUR-FIREBASE-APP-P12.p12");
FirebaseApp.DefaultInstance.SetEditorServiceAccountEmail("[email protected]");
FirebaseApp.DefaultInstance.SetEditorP12Password("notasecret");
}
I got the following hint:
Method 'Firebase.Unity.Editor.FirebaseEditorExtensions.SetEditorP12FileName' is obsolete: Service account in editor is no longer supported. Please use standard sign-in methods instead, ex. FirebaseAuth.SignInWithEmailAndPasswordAsync()
This brought me to the Firebase Deprecated page which says:

Now I don't know how to add the Admin SDK to my Unity project. I can only find references about how to add the Admin SDK to a server. But how can I add the Admin SDK to an Unity project?
I wrote a mail to the Firebase Support and even wrote in the Firebase Community Slack channel and the reference on how to add the Admin SDK to a server seems to be the way to go for unity projects as well.
Here is what I did (in case someone want to save some time):
FirebaseApp.Create(new AppOptions()
{
Credential = GoogleCredential.GetApplicationDefault(),
});
Important: after copying the code snippet and importing the dependencies, my IDE imported the Firebase package instead of the FirebaseAdmin package which of course don't work and the parameter Credential can't be found as part of AppOptions. So make sure to use the correct dependency.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With