我有一个用 VB.Net 编写的 Windows 桌面应用程序。我的服务器需要与 Firebase 连接以将更新发送到该应用程序(Firebase 实时数据库)。现在,我可以使用服务帐户中的“数据库机密”来执行此操作,但由于此功能已弃用,我想使用较新的 Firebase Admin SDK。
我不需要任何用户的实际身份验证,因为这是使用服务帐户。
有没有办法可以使用管理 SDK 或任何第 3 方库(针对 .NET)来实现这一点。我的搜索并没有取得任何成功。
这是我的第一个问题。如果有人能引导我走向正确的方向,我将不胜感激。
Firebase Admin SDK 已发布一段时间,您可以在此处找到存储库:https://github.com/firebase/firebase-admin-dotnet https://github.com/firebase/firebase-admin-dotnet
请记住,与其他管理 SDK 相比,这是非常有限的。
如何使用:
// 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);
更多信息:https://firebase.google.com/docs/admin/setup https://firebase.google.com/docs/admin/setup
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)