FireSharp
FireSharp copied to clipboard
Connect to firebase as a specific user
During my initial tests, I've connected to firebase, using the firesharp code below, which works fine. How do I connect as a specific user, applying their security rules? I didn't see a way to pass in their identifier and UID.
Private objConfig As IFirebaseConfig
Private objClient As IFirebaseClient
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Try
objConfig = New FirebaseConfig()
With objConfig
.BasePath = "https://<my base url>/"
.AuthSecret = "<my auth secret>"
End With
objClient = New FireSharp.FirebaseClient(objConfig)
Catch ex As Exception
MessageBox.Show("Connection Failed")
End Try
End Sub
Hi @tblack2200, for using the firebase rules you would need to authenticate the user first through Firebase Authentication, you can't pass your own 'security context'. I haven't been involved in FireSharp in a while but as far as I know FireSharp only provides access to the Firebase Database.
You can use firebase-authentication-dotnet to Authenticate your user and get Auth object . from there get the Firebase token Auth.FirebaseToken
then use it in FireSharp Config
IFirebaseConfig config = new FireSharp.Config.FirebaseConfig
{
RequestTimeout = TimeSpan.FromDays(1),
BasePath = "https://calm-seeker-257120.firebaseio.com/",
AuthSecret = auth.FirebaseToken
};