7

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.

tempUser
  • 71
  • 1
  • 1
  • 3
  • Now Firebase Admin SDK is available for the .NET environment [answer](https://stackoverflow.com/a/54987702/7174852) – Maksym Labutin Mar 04 '19 at 16:45
  • Possible duplicate of [Add user claims to firebase auth from asp.net core api](https://stackoverflow.com/questions/51231972/add-user-claims-to-firebase-auth-from-asp-net-core-api) – Dominik May 27 '19 at 20:11

2 Answers2

9

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

Dominik
  • 649
  • 7
  • 16
4

There's currently no Firebase Admin SDK available for the .NET environment. 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.

Hiranya Jayathilaka
  • 7,180
  • 1
  • 23
  • 34