title: Firebase Geofire permission denied
body: <p>I'm using Firebase Geofire to get user locations to store them in my database. I get an error when I try to run a query:</p>
  
  <p><code>Listener at /RDio5CZF2fcJTUOcaeNJhuvYP2Q2 failed: permission_denied
  2017-09-19 22:34:24.809 HeartQuest[26419] &lt;Warning&gt; [Firebase/Database][I-RDB038012] Listener at /RDio5CZF2fcJTUOcaeNJhuvYP2Q2 failed: permission_denied
  An error occurred getting the location for "firebase-hq": Optional("Permission Denied")</code></p>
  
  <p>The errors occur after running the following query:</p>
  
  <pre><code>    let userID = User.current?.key
      let geofireRef = Database.database().reference()
      let geoFire = GeoFire(firebaseRef: geofireRef)
      geoFire?.getLocationForKey(userID!, withCallback: { (location, error) in
          if (error != nil) {
              print("An error occurred getting the location for \"firebase-hq\": \(error?.localizedDescription)")
          } else if (location != nil) {
              print("Location for \"firebase-hq\" is [\(location?.coordinate.latitude), \(location?.coordinate.longitude)]")
          } else {
              print("GeoFire does not contain a location for \"firebase-hq\"")
          }
      })
  }
  </code></pre>
  
  <p>Can anyone please explain what the location key is and why I might not have permission for it? I'm using <code>CLLocationManager</code> to request the user's permission for their phone's location.</p>
  
  <p>EDIT: Firebase rules</p>
  
  <pre><code>{
    "rules": {
      ".validate": "auth != null",
      ".write": "auth != null",
      "users" : {
        ".read": "auth != null",
        ".indexOn" : ["email","username"],
        "$userId": {
          ".write": "data.val() == null || (newData.val() == null &amp;&amp; $userId === auth.uid)"
        }
      }
    }
  }
  </code></pre>