1

I am trying to add text(32424234) into my firebase under the userid of the user but it doesnt let me do it.

This is my rules section under firebase

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

This is my java code:

public void kullanicikontrol(String kullaniciadi){
        mRootRef = new Firebase("https://xxxx.firebaseio.com/users");
        Firebase chieldref = mRootRef.child(kullaniciadi);
        chieldref.setValue("32424234");
}

if i change rules like ".read": true" there is no problem like the screenshot below:

enter image description here

but i dont want to. What i am doing wrong?

1
  • The code you added in your comment below uses the "new" Firebase SDK (launched at I/O 2016). The code in your question uses the older Firebase SDK that predates that. Authentication in the newer SDK does not apply to database access using the older SDK. To fix the problem, update your database code to use the new SDK too: firebase.google.com/docs/database Commented Jun 5, 2017 at 7:06

1 Answer 1

1

In firebase .read and .write is read write permission. If you set it to true than it allow all user.

You can create new user and authentication by following link https://firebase.google.com/docs/auth/web/manage-users

I hope this will help you.

Sign up to request clarification or add additional context in comments.

2 Comments

I am getting the uid a little bit different from the post you mentioned. FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if (user != null) { // Name, email address, and profile photo Url String name = user.getDisplayName(); String email = user.getEmail(); Uri photoUrl = user.getPhotoUrl(); String uid = user.getUid(); kullanici = new database(); kullanici.kullanicikontrol(uid); } is it wrong?
The user's ID, unique to the Firebase project. Do NOT use this value to authenticate with your backend server, if you have one. Use User.getToken() instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.