0
votes

I have set my firebase database rules to "auth != null" and to access the database through http request I can pass the auth Token with the api endpoint url like http.get('url?auth=<auth-token>'). But I want to access the firebase database through firebase SDK.

    firebase.database().ref('users'+ userId).on('value',(snapShot)=>{
        this.setState({user: snapShot.val()});
    }) 

Here I am not getting any response because my database rule is set to "auth != null". So how can I pass the auth detail in this request.

1
As far as I know only Firebase Cloud Functions using Admin SDK can by pass the Firebase Database rules.Dharmaraj

1 Answers

0
votes

You'll want to sign in the user with Firebase Authentication into your React app. Once you do so, the token will automatically be passed to the Realtime Database by the Firebase Authentication SDK.