Xamarin访问使用Nuget软件包firebaseauthentication.net的firebase实时数据库

发布于 2025-02-09 21:14:57 字数 1395 浏览 0 评论 0原文

IM在Firebase中的初学者和IM使用两个Nuget软件包FirebaseAthentication.net和firebaseadatabase.net。 IM试图写入一个受保护的Firebase实时数据库,该数据库具有看起来像这样的规则,

{
  "rules": {
    
    ".read": "auth.uid != null",
    ".write": "auth.uid != null"
  }
}

我随机尝试了signwithoAuthasync方法,但是它会引发异常[邮件auth类型类型connot被这样使用。使用方法指定来发送电子邮件&密码身份验证]

 private async void Button_Clicked(object sender, EventArgs e)
        {

            try
            {
                var authProvider = new FirebaseAuthProvider(new FirebaseConfig(webApiKey));
                var savedfirebaseauth = JsonConvert.DeserializeObject<FirebaseAuth>(Preferences.Get("MyFirebaseRefreshToken", ""));
                await authProvider.SignInWithOAuthAsync(FirebaseAuthType.EmailAndPassword, savedfirebaseauth.FirebaseToken);
                

                //inserting info into the database
               
                await firebaseClient.Child("users").Child("some uid1").PutAsync(new userinfo
                {

                    firstName = "noor",
                    secondName = "mohammed"
                });

                //clear the entry
                recordData.Text = "";

            }catch(Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("Alert", ex.Message, "OK");
            }
        }

请求让我知道我的问题是否需要更澄清,谢谢。

im beginner in firebase and im using two nuget packages FirebaseAuthentication.net and FirebaseDatabase.net .
im trying to write to a protected firebase realtime database that has a rule that look like this

{
  "rules": {
    
    ".read": "auth.uid != null",
    ".write": "auth.uid != null"
  }
}

i randomly tryed SignInWithOAuthAsync method however it throws an Exception [ mail auth type connot be used like this. use method specifc to email & password authentication]

 private async void Button_Clicked(object sender, EventArgs e)
        {

            try
            {
                var authProvider = new FirebaseAuthProvider(new FirebaseConfig(webApiKey));
                var savedfirebaseauth = JsonConvert.DeserializeObject<FirebaseAuth>(Preferences.Get("MyFirebaseRefreshToken", ""));
                await authProvider.SignInWithOAuthAsync(FirebaseAuthType.EmailAndPassword, savedfirebaseauth.FirebaseToken);
                

                //inserting info into the database
               
                await firebaseClient.Child("users").Child("some uid1").PutAsync(new userinfo
                {

                    firstName = "noor",
                    secondName = "mohammed"
                });

                //clear the entry
                recordData.Text = "";

            }catch(Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("Alert", ex.Message, "OK");
            }
        }

pleace let me know if my question needs more Clarificatio thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文