使用c#应用程序和Firebase身份验证登录

时间:2019-08-25 11:51:32

标签: c# firebase firebase-realtime-database firebase-authentication

我已经建立了一个实时Firebase数据库,该数据库将用于存储大学项目的一些信息。因此,仅琐碎的数据将被存储而没有敏感信息。我想创建一个可以使用内置Firebase身份验证登录的C#应用​​程序。

我已使用以下代码成功将c#和firebase连接在一起

IFirebaseConfig ifc = new FirebaseConfig()
    {
        AuthSecret = "secretcode",
        BasePath = "https://mydbpath/"
    };

    IFirebaseClient client; 

现在我希望能够将新用户添加到Firebase并让他们登录。 我注意到IFirebaseClient具有

CreateUser(string email , String passwword) 

但是我不确定如何使用它们,因为当我只是尝试在按钮上添加用户时,单击我会收到以下错误。

FireSharp.Exceptions.FirebaseException: Request responded with status 
code=MethodNotAllowed, response=<html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx</center>
</body>
</html>

我不确定这是否与我在Firebase中的设置或我的ciode的实现有关,因此,非常感谢与文档或帮助的任何链接。

1 个答案:

答案 0 :(得分:0)

在您的Firebase实时数据库中,请确保您已正确配置规则,以便读取或更改如下数据:

{
  "rules": {
    "users": {
      "$uid": {
        ".read": "$uid === auth.uid",
        ".write": "$uid === auth.uid"
      }
    }
  }
}

更多信息:https://firebase.google.com/docs/database/security