title: Firebase & Pyrebase can't write to database with Authentication
body: <p>I am farely new to Pyrebase and Firebase and I was wondering why this code isn't working.
  I want to write to the realtime database, for that the rules are</p>
  <pre><code>{
    &quot;rules&quot;: {
      &quot;userdata&quot;: {
        &quot;$uid&quot;: {
              &quot;.read&quot;: &quot;$uid === auth.uid&quot;,
              &quot;.write&quot;: &quot;$uid === auth.uid&quot;
          }
          }
      }  
  }
  </code></pre>
  <p>And the python code is:</p>
  <pre><code>def login():
      email = input(&quot;Enter email: &quot;)
      password = input(&quot;Enter password: &quot;)
      user = auth.sign_in_with_email_and_password(email, password)
      user = auth.refresh(user['refreshToken'])
      uid_variable = user['userId']
      print(uid_variable)
      print(&quot;Successfully logged in!&quot;)
      data = {&quot;test&quot;: &quot;test&quot;}
      db.child(&quot;userdata&quot;).child(uid_variable).set(data)
  </code></pre>
  <p>But when it tries to write to the database it shows:</p>
  <pre><code> [Errno 401 Client Error: Unauthorized for url: https://xxxxxxxxxx-default-rtdb.europe-west1.firebasedatabase.app/userdata/xxxxxxxxxxxxxxxxxxxxxxxx.json] {
    &quot;error&quot; : &quot;Permission denied&quot;
  }
  </code></pre>
  <p>I don't seem to find any help anywhere so anything would be appreciated!</p>