I have a windows desktop app written in VB.Net.My server needs to connect with the Firebase to send updates to the app (Firebase Realtime Database). Right now I am able to do this using the "Database secrets" in the service accounts, but since this is deprecated, I would like to use the newer Firebase Admin SDK. I will not be needing the actual authentication of any users since this is using a service account. Is there a way I could use the admin SDK or any 3rd Party library (for .NET) which will allow me to do that. My search didn't turn out to have any success. This is my first question here. I appreciate if somebody could direct me in the right direction.
The Firebase Admin .NET SDK enables access to Firebase services from privileged environments (such as servers or cloud) in .NET. Currently this SDK provides Firebase custom authentication support. For more information, please visit the Firebase Admin SDK setup guide.
Firebase automatically provisions resources for your Firebase project. When the process completes, you'll be taken to the overview page for your Firebase project in the Firebase console. If you are setting up a new project, you need to install the SDK for the language of your choice. The Firebase Admin Node.js SDK is available on npm.
But you can use the Firebase REST API with an OAuth token. You will have to use a .NET library to kick off the OAuth flow, and obtain a token. Update: Firebase Admin .NET SDK is now available. See Dominik's reply.
Access Google Cloud Platform resources like Cloud Storage buckets and Cloud Firestore databases associated with your Firebase projects. Create your own simplified admin console to do things like look up user data or change a user’s email address for authentication. To use Admin SDK, you need to add firebase-admin npm package to your project first:
The Firebase Admin SDK was released some time ago and you can find the repository here: https://github.com/firebase/firebase-admin-dotnet
Keep in mind that this is very limited compared to the other admin SDKs.
How to use:
// Initialize the admin SDK with your service account keys.
// This should be called before using the admin SDK e.g. Startup.cs in ASP.NET Core.
// There are other config loader methods besides of FromFile e.g. FromJson etc.
FirebaseApp.Create(new AppOptions()
{
Credential = GoogleCredential.FromFile("path/to/serviceAccountKey.json"),
});
// Then FirebaseAuth.DefaultInstance will give you the initialized SDK Auth instance.
// E.g.:
await FirebaseAuth.DefaultInstance.SetCustomUserClaimsAsync(uid, claims);
More info: https://firebase.google.com/docs/admin/setup
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