如何在.NET中使用Firebase Admin SDK?

编程入门 行业动态 更新时间:2024-10-21 14:44:54
本文介绍了如何在.NET中使用Firebase Admin SDK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个用VB.Net编写的Windows桌面应用程序.我的服务器需要与Firebase连接才能将更新发送到该应用程序(Firebase实时数据库).现在,我可以使用服务帐户中的数据库机密"来执行此操作,但是由于不建议使用此功能,因此我想使用较新的Firebase Admin SDK. 我将不需要任何用户的实际身份验证,因为它使用的是服务帐户. 有没有一种方法可以使用admin SDK或任何第三方库(用于.NET),这将使我能够做到这一点.我的搜索结果没有成功. 这是我的第一个问题.我很高兴有人可以指引我正确的方向.

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.

推荐答案

Firebase Admin SDK已于不久前发布,您可以在此处找到存储库: github/firebase/firebase-admin-dotnet

The Firebase Admin SDK was released some time ago and you can find the repository here: github/firebase/firebase-admin-dotnet

请记住,与其他管理SDK相比,这是非常有限的.

Keep in mind that this is very limited compared to the other admin SDKs.

使用方法:

// 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);

更多信息: firebase.google/docs/admin/setup

更多推荐

如何在.NET中使用Firebase Admin SDK?

本文发布于:2023-11-28 07:21:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641451.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   NET   Firebase   Admin   SDK

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!