im doing an C# app with .NET Windows Forms Framework and i have a permission dennied error when i try to send information to realtime db, but im have logged in in the app. The security of my Firebase Realtime DB is the following:
{
"rules":{
".read": "auth.uid != null",
".write": "auth.uid != null"
}
}
im using FirebaseAuthentication.net (v3.7.1) and FirebaseDatabase.net (v4.2.0) from Step Up Labs
using Firebase.Database;
using Firebase.Database.Query;
using Firebase.Auth;
the code where the Permission Dennied Errors ocurred is the following
private async void button_reg_Click(object sender, EventArgs e)
{
authProvider = new FirebaseAuthProvider(new FirebaseConfig("my_api_key"));
var authResult = await authProvider.SignInWithEmailAndPasswordAsync("a mail that exists on firebase auth", "the correct password");
if (authResult != null)
{
var user = new Users()
{
Address = "Country",
LastName = "Doe",
Name = "John"
};
var client = getFirebaseClient();
await client.Child(nameof(Users))
.PostAsync(user);
}
}
private FirebaseClient getFirebaseClient()
{
return new FirebaseClient("my_database_url");
}
class users is
public class Users
{
public string Name { get; set; }
public string LastName { get; set; }
public string Key { get; set; }
public string Address { get; set; }
}
the code passes authResult!=null but then in this line “await client.Child(nameof(Users))
.PostAsync(user);” the following error ocurres
Firebase.Database.FirebaseException: 'Exception occured while processing the request.
Url: https://project-projectNumber-default-rtdb.firebaseio.com/Users/-NwVBBRKfhiWk5R1ISC5/.json?print=silent
Request Data: {"Name":"John","LastName":"Doe","Key":null,"Address":"Country"}
Response: {
"error" : "Permission denied"
}
'
i dont understand where the problem is, i hope someone have the answer
Agus is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.